3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(){ $variable = "first"; $closure = function() { global $variable; echo $variable . "\n"; }; $closure(); function test($closure) { global $variable; //Note the scope added here $variable = "second"; $closure(); } test($closure); } foo(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ipTfO
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0          
   25     2      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ipTfO
function name:  foo
number of ops:  10
compiled vars:  !0 = $variable, !1 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'first'
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FipTfO%3A5%240'
          2        ASSIGN                                                   !1, ~3
   11     3        INIT_DYNAMIC_CALL                                        !1
          4        DO_FCALL                                      0          
   13     5        DECLARE_FUNCTION                                         'test'
   21     6        INIT_FCALL_BY_NAME                                       'test'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
   22     9      > RETURN                                                   null

End of function foo

Function %00%7Bclosure%7D%2Fin%2FipTfO%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ipTfO
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_GLOBAL                                              !0, 'variable'
    8     1        CONCAT                                           ~1      !0, '%0A'
          2        ECHO                                                     ~1
    9     3      > RETURN                                                   null

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

Function %00test%2Fin%2FipTfO%3A13%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ipTfO
function name:  test
number of ops:  6
compiled vars:  !0 = $closure, !1 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        BIND_GLOBAL                                              !1, 'variable'
   16     2        ASSIGN                                                   !1, 'second'
   18     3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0          
   19     5      > RETURN                                                   null

End of function %00test%2Fin%2FipTfO%3A13%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.13 ms | 1399 KiB | 14 Q