I want to use register_tick_function() to hook the following calls and print their stack trace with debug_backtrace().
If I run the following code.
<?php
function dump() {
// Replace this with var_dump(debug_backtrace()); to print the entire trace.
foreach (debug_backtrace() as $trace)
echo("Function ${trace['function']}() has been called" . PHP_EOL);
}
declare(ticks = 1);
register_tick_function('dump');
print("");
array_search('green', Array());
It prints only the dump() function.
Function dump() has been called
Function dump() has been called
Function dump() has been called
Why I'm not seeing print() and array_search() trace data? It's like the stack has been reset before invoking dump(). I'm also pretty sure it worked properly in the past.
print("");dump();array_search('green', Array());dump();So in this case, it really is tracing itself since it is not being called from inside anything else.