3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = 0; $result2 = 1; $one = function() { var_dump($result); }; $two = function() use ($result) { var_dump($result); }; $three = function() use (&$result) { var_dump($result); }; $four = function($result) use (&$result2) { 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/hWTqh
function name:  (null)
number of ops:  21
compiled vars:  !0 = $result, !1 = $result2, !2 = $one, !3 = $two, !4 = $three, !5 = $four
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 0
    3     1        ASSIGN                                                   !1, 1
    5     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhWTqh%3A5%240'
          3        ASSIGN                                                   !2, ~8
    8     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhWTqh%3A8%241'
          5        BIND_LEXICAL                                             ~10, !0
          6        ASSIGN                                                   !3, ~10
   11     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhWTqh%3A11%242'
          8        BIND_LEXICAL                                             ~12, !0
          9        ASSIGN                                                   !4, ~12
   14    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhWTqh%3A14%243'
         11        BIND_LEXICAL                                             ~14, !1
         12        ASSIGN                                                   !5, ~14
   17    13        PRE_INC                                                  !0
   19    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
   20    16        INIT_DYNAMIC_CALL                                        !3
         17        DO_FCALL                                      0          
   21    18        INIT_DYNAMIC_CALL                                        !4
         19        DO_FCALL                                      0          
   22    20      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FhWTqh%3A5%240

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

End of function %00%7Bclosure%7D%2Fin%2FhWTqh%3A8%241

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

End of function %00%7Bclosure%7D%2Fin%2FhWTqh%3A11%242

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

End of function %00%7Bclosure%7D%2Fin%2FhWTqh%3A14%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146 ms | 1400 KiB | 15 Q