3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = 0; $one = function() { var_dump($result); }; $two = function() use ($result) { var_dump($result); }; $three = function() use (&$result) { var_dump($result); }; $result++; $one(); // outputs NULL: $result is not in scope $two(); // outputs int(0): $result was copied $three(); // outputs int(1) ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dLn0V
function name:  (null)
number of ops:  17
compiled vars:  !0 = $result, !1 = $one, !2 = $two, !3 = $three
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 0
    4     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdLn0V%3A4%240'
          2        ASSIGN                                                   !1, ~5
    7     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdLn0V%3A7%241'
          4        BIND_LEXICAL                                             ~7, !0
          5        ASSIGN                                                   !2, ~7
   10     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdLn0V%3A10%242'
          7        BIND_LEXICAL                                             ~9, !0
          8        ASSIGN                                                   !3, ~9
   13     9        PRE_INC                                                  !0
   15    10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0          
   16    12        INIT_DYNAMIC_CALL                                        !2
         13        DO_FCALL                                      0          
   17    14        INIT_DYNAMIC_CALL                                        !3
         15        DO_FCALL                                      0          
   18    16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdLn0V%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dLn0V
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAR                                                 !0
          2        DO_ICALL                                                 
          3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdLn0V%3A4%240

Function %00%7Bclosure%7D%2Fin%2FdLn0V%3A7%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dLn0V
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   BIND_STATIC                                              !0
    8     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdLn0V%3A7%241

Function %00%7Bclosure%7D%2Fin%2FdLn0V%3A10%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dLn0V
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   BIND_STATIC                                              !0
   11     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdLn0V%3A10%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.97 ms | 1400 KiB | 15 Q