PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Zafar Iqbal  >  Stopwatch  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Stopwatch
Measure partial and final time between events
Author: By
Last change:
Date: 17 years ago
Size: 1,010 bytes
 

Contents

Class file image Download
<?php

// Include the source for class
require_once("class-stopwatch.php");

// Creates a new object
$o = new Stopwatch();

// The first call to lap starts the stopwatch.
// The parameter is a convenient label for display.
// If no parameter is given a default string is used.
$o->lap('1st lap - they have started!');

// Sleep for a tiny bit and then call the lap method with a suitable label.
usleep(100000);
$o->lap('2nd lap - they are speeding!');

// Sleep for a tiny bit and then call the lap method with a suitable label.
usleep(300000);
$o->lap('3rd lap - hmm getting slower!');

// Sleep for a tiny bit and then call the lap method with a suitable label.
usleep(400000);
$o->lap('4th lap - could this be the slowest?!?!');

// Sleep for a tiny bit and then call the lap method with a suitable label.
usleep(200000);
$o->lap('5th lap - abit better!');

// If the boolean 'true' is passed as a parameter then output will include a HTML <BR> for each newline.
// Handy for web output.
$o->display();

?>

For more information send a message to info at phpclasses dot org.