If, however, you hit refresh, the array ($duh) gets longer and longer - as if DESPITE the fact that we clear the array at the beginning, it has a "memory" of it.
This is on php-4.3.8 (fedora core2), with register_globals OFF.
Why does the count of $duh get longer with each refresh, and why doesnt setting it to a blank string clear it?
I've never used ticks before, and this behavior seems to defy normal behavior..
Code: Select all
<?php
echo "<html><body>";
// A function that records the time when it is called
$duh[] = '';
var_dump($duh);
function profile ($dump = FALSE)
{
static $duh;
// Return the times stored in profile, then erase it
if ($dump)
{
return ($duh);
}
else
{
$duh[] = microtime ();
}
}
// Set up a tick handler
register_tick_function("profile");
// Initialize the function before the declare block
profile();
// Run a block of code, throw a tick every statement.
declare (ticks=1)
{
echo ".";
}
// Display the data stored in the profiler
echo "<br><pre>";
print_r (profile (TRUE));
echo "</pre></body></html>";
// Try to kill the phantom values..
unset($duh);
unregister_tick_function("profile");
die();
?>