Created
February 14, 2013 15:49
-
-
Save markkelnar/4953672 to your computer and use it in GitHub Desktop.
Fun with ticks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(ticks=1); | |
// A function called on each tick event | |
function tick_handler() | |
{ | |
echo "tick_handler() called\n"; | |
$trace = debug_backtrace(); | |
if (count($trace) <= 1) { | |
return; | |
} | |
print_r($trace); | |
$frame = $trace[1]; | |
unset($trace); | |
$function = $frame['function']; | |
echo __FUNCTION__ . ' :: ' . $function . PHP_EOL; | |
} | |
register_tick_function('tick_handler'); | |
$a = 1; | |
if ($a > 0) { | |
$a += 2; | |
print($a); | |
} | |
do_something(); | |
function do_something() { do_more(); } | |
function do_more() { } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment