Tedd's microtime()

The following is an example of microtime() function

This script took: 0.01075 seconds to execute

 

CODE FOLLOWS

<?php            
    
include('includes/header.php');

    
error_reporting(E_ALL);    // set error reporting to all
                        
    
echo("<h1> Tedd's microtime()</h1>");
                        
    echo(
'<h2>The following is an example of microtime() function</h2>');

    
// start clock 
                     
    
$starttime microtime(); 
    
$startarray explode(" "$starttime); 
    
$starttime $startarray[1] + $startarray[0]; 
    
    
// do 1 million counts
    
    
for ($i=1$i 1000000$i++)
        {
        
$a $i;
        }

    
// stop clock
                    
    
$endtime microtime(); 
    
$endarray explode(" "$endtime); 
    
$endtime $endarray[1] + $endarray[0]; 
    
$totaltime $endtime $starttime;  
    
$totaltime round($totaltime,5);     // round to five places
     
     // show time elapsed
     
    
echo("<p>This script took: $totaltime seconds to execute</p>");  
            
    include(
'includes/footer.php');
?>