你可以
register一
tick handler:
Ticks
A tick is an event that occurs for every N low-level tickable statements executed by the parser within the declare block. The value for N is specified using ticks=N within the declare blocks’s directive section.
Not all statements are tickable. Typically, condition expressions and argument expressions are not tickable.
正如您所看到的,它不完全是“每行代码”,除非您每行只写一个可选择的语句.但它是你能得到的最接近的.
例:
declare(ticks=1);
register_tick_function(function() {
echo "tick_handler() called\n";
});
echo 'Line 1', PHP_EOL;
echo 'Line 2', PHP_EOL;
echo strtoupper('Line 3'), PHP_EOL;
将输出(demo):
tick_handler() called
Line 1
tick_handler() called
Line 2
tick_handler() called
LINE 3
tick_handler() called