Skip to content

Instantly share code, notes, and snippets.

@markkelnar
Created February 14, 2013 15:49
Show Gist options
  • Save markkelnar/4953672 to your computer and use it in GitHub Desktop.
Save markkelnar/4953672 to your computer and use it in GitHub Desktop.
Fun with ticks.
<?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