3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sum = null; // global variable function outer() { global $sum; $hundred_more = 100; $sum = function ($a, $b) use ($hundred_more) { return $a + $b + (++$hundred_more); }; var_dump($hundred_more); } outer(); // define sum at the global scope and print 100 var_dump($sum(5, 10)); // 116 var_dump($sum(5, 10)); // 117 outer(); // redefine sum at the global scope and print 100 var_dump($sum(5, 10)); // 116 var_dump($sum(5, 10)); // 117
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XKE7j
function name:  (null)
number of ops:  34
compiled vars:  !0 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, null
   13     1        INIT_FCALL                                               'outer'
          2        DO_FCALL                                      0          
   14     3        INIT_FCALL                                               'var_dump'
          4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              5
          6        SEND_VAL_EX                                              10
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
   15    10        INIT_FCALL                                               'var_dump'
         11        INIT_DYNAMIC_CALL                                        !0
         12        SEND_VAL_EX                                              5
         13        SEND_VAL_EX                                              10
         14        DO_FCALL                                      0  $5      
         15        SEND_VAR                                                 $5
         16        DO_ICALL                                                 
   16    17        INIT_FCALL                                               'outer'
         18        DO_FCALL                                      0          
   17    19        INIT_FCALL                                               'var_dump'
         20        INIT_DYNAMIC_CALL                                        !0
         21        SEND_VAL_EX                                              5
         22        SEND_VAL_EX                                              10
         23        DO_FCALL                                      0  $8      
         24        SEND_VAR                                                 $8
         25        DO_ICALL                                                 
   18    26        INIT_FCALL                                               'var_dump'
         27        INIT_DYNAMIC_CALL                                        !0
         28        SEND_VAL_EX                                              5
         29        SEND_VAL_EX                                              10
         30        DO_FCALL                                      0  $10     
         31        SEND_VAR                                                 $10
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function outer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XKE7j
function name:  outer
number of ops:  9
compiled vars:  !0 = $sum, !1 = $hundred_more
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_GLOBAL                                              !0, 'sum'
    7     1        ASSIGN                                                   !1, 100
    8     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXKE7j%3A8%240'
          3        BIND_LEXICAL                                             ~3, !1
          4        ASSIGN                                                   !0, ~3
   11     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   12     8      > RETURN                                                   null

End of function outer

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

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.16 ms | 1403 KiB | 17 Q