什么是PHP中的低级别可选语句

PHP version:5.3.3

Here is the example:

<?php
    declare(ticks=1);
    // declare(ticks=2);
    function handler()
    {
        echo "handler called
";
    }
    register_tick_function('handler');
    $a = 1;
    // Output: handler called
handler called
 
?>

The Output is the same handler called handler called whenever assign the var ticks as 1 or 2.

Below is the opcode generated by vld:

Finding entry points
Branch analysis from position: 0
Return found
filename:       /home/soooldier/Php/2.php
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   2     0  >   TICKS                                                    1
         1      TICKS                                                    1
   4     2      NOP                                                      
   7     3      TICKS                                                    1
   8     4      SEND_VAL                                                 'handler'
         5      DO_FCALL                                      1                  'register_tick_function'
         6      TICKS                                                    1
   9     7      ASSIGN                                                   !0, 1
         8      TICKS                                                    1
  10     9    > RETURN                                                   1

branch: #  0; line:     2-   10; sop:     0; eop:     9
path #1: 0, 
Function handler:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /home/soooldier/Php/2.php
function name:  handler
number of ops:  3
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   6     0  >   ECHO                                                     'handler+called%0A'
         1      TICKS                                                    1
   7     2    > RETURN                                                   null

branch: #  0; line:     6-    7; sop:     0; eop:     2
path #1: 0, 
End of function handler.

**In php manual,it says:

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.**

But in the example script, The output is the same whenever assign ticks as 1 or 2

dsgsdg206050
dsgsdg206050 谢谢你的提醒。我在这个问题的尾部添加了我的困惑。
接近 7 年之前 回复
dsaf4351321
dsaf4351321 你能解释实际问题吗?你对蜱感到困惑的是什么?
接近 7 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐