PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Joshua Townsend   Code Timer   example1.php   Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example of using class to see how long a function takes to execute
Class: Code Timer
Measure the time a PHP script takes to execute
Author: By
Last change:
Date: 17 years ago
Size: 433 bytes
 

Contents

Class file image Download
<?php
require "timer.class.php"; // Get the timer class

// Simplest way to use this class:

$timer = new timer(); // Create an object; automatically starts timer unless called as timer(false)
$contents = file_get_contents("http://www.example.com"); // Example of code that might take a while to execute
$time = $timer->stop(); // Stop the timer and get the execution time

echo "Contents retrieved in {$time} seconds.";
?>