Usage of Uptime in PHP-Scripts

Ihre Sprache: Diese Seite in deutsch

Contents: Example


The following example will show the usage of uptime in a simle php script. It requirest the uptime.exe application to be placed in the windows directory or the windows system directory.

01 <html>

02 <head>

03 <title>UP TIME of localhost</title>

04 </head>

05 <body>

06 <h1>UP TIME of localhost</h1>

07 <p>Here are the UP TIME data</p><pre>

08 <?

09 $cmd = "uptime /a";

10 $out = array();

11 exec($cmd, $out);

12 for($i=0; $i < count($out); $i++) { echo $out[$i]."\n"; }

13 ?>

14 </pre>

15 </body>

16 </html>

Line 09 sets the command line for the execution of uptime. Uptime is executed with the php command exec in line 11. The console output is covered inside the array $out. The for-iteration in line 12 writes the console output to the web browser.

A website created with the script above may look like this:

UP TIME of localhost

Here are the UP TIME data

0 years
0 days
3 hours
53 minutes
28 seconds

Last change of page 2004/12/29, Copyright ©2004 Michael Berthold

Navigation: Back to Full Copy | To start of page

Valid XHTML 1.0! Valid CSS!