What’s wrong with microtime?

Posted on: January 5, 2011 Posted by: John Huh Comments: 0

What’s wrong with microtime?

Calling PHP function microtime() returns two sets of numbers. Below code was puzzling me for a while but came down to one parameter which needs to be included in the microtime() function call.

TRUE!!!!
microtime(TRUE) is required to return the time as a float value.

[php]
if ($debug === TRUE)
{
echo ‘<pre>’;
print_r($sql);
echo ‘</pre>’;
$debug_start_time = microtime(TRUE);
}

$rs_select1->db_query($sql);

if ($debug === TRUE)
{
$debug_end_time = microtime(TRUE);
echo sprintf("Elapsed <b>%f</b> seconds", $debug_end_time – $debug_start_time);
}

[/php]

Leave a Reply:

Your email address will not be published. Required fields are marked *