我想用来register_tick_function()挂钩以下调用并打印他们的堆栈跟踪debug_backtrace().
如果我运行以下代码.
<?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());
Run Code Online (Sandbox Code Playgroud)
它只打印dump()功能.
Function dump() has been called
Function dump() has been called
Function dump() has been called
Run Code Online (Sandbox Code Playgroud)
为什么我没有看到print()和array_search()跟踪数据?就像堆栈在调用之前已经重置一样dump().我也很确定它在过去是否正常工作.