3v4l.org

run code in 300+ PHP versions simultaneously
<?php $nowdoc = <<<'END' Multi line string END; $inc = function ($x) { return $x + 1; }; echo $inc(2); // => 3 function foo ($x, $y, $z) { echo "$x - $y - $z"; } function bar ($x, $y) { return function ($z) use ($x, $y) { foo($x, $y, $z); }; } $bar = bar('A', 'B'); $bar('C'); // 输出 "A - B - C" echo $nowdoc;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kjvIG
function name:  (null)
number of ops:  17
compiled vars:  !0 = $nowdoc, !1 = $inc, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'Multi+line%0Astring'
    8     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FkjvIG%3A8%240'
          2        ASSIGN                                                   !1, ~4
   12     3        INIT_DYNAMIC_CALL                                        !1
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0  $6      
          6        ECHO                                                     $6
   24     7        INIT_FCALL                                               'bar'
          8        SEND_VAL                                                 'A'
          9        SEND_VAL                                                 'B'
         10        DO_FCALL                                      0  $7      
         11        ASSIGN                                                   !2, $7
   25    12        INIT_DYNAMIC_CALL                                        !2
         13        SEND_VAL_EX                                              'C'
         14        DO_FCALL                                      0          
   27    15        ECHO                                                     !0
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FkjvIG%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kjvIG
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
   10     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FkjvIG%3A8%240

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kjvIG
function name:  foo
number of ops:  10
compiled vars:  !0 = $x, !1 = $y, !2 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   15     3        ROPE_INIT                                     5  ~4      !0
          4        ROPE_ADD                                      1  ~4      ~4, '+-+'
          5        ROPE_ADD                                      2  ~4      ~4, !1
          6        ROPE_ADD                                      3  ~4      ~4, '+-+'
          7        ROPE_END                                      4  ~3      ~4, !2
          8        ECHO                                                     ~3
   16     9      > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kjvIG
function name:  bar
number of ops:  7
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FkjvIG%3A19%241'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   21     5      > RETURN                                                   ~2
   22     6*     > RETURN                                                   null

End of function bar

Function %00%7Bclosure%7D%2Fin%2FkjvIG%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kjvIG
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $z, !1 = $x, !2 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   20     3        INIT_FCALL                                               'foo'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
   21     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FkjvIG%3A19%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.23 ms | 1407 KiB | 15 Q