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 echo($sum(5, 10)); // 116 echo($sum(5, 10)); // 117 outer(); // redefine sum at the global scope and print 100 echo($sum(5, 10)); // 116 echo($sum(5, 10)); // 117
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86kk0
function name:  (null)
number of ops:  26
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_DYNAMIC_CALL                                        !0
          4        SEND_VAL_EX                                              5
          5        SEND_VAL_EX                                              10
          6        DO_FCALL                                      0  $3      
          7        ECHO                                                     $3
   15     8        INIT_DYNAMIC_CALL                                        !0
          9        SEND_VAL_EX                                              5
         10        SEND_VAL_EX                                              10
         11        DO_FCALL                                      0  $4      
         12        ECHO                                                     $4
   16    13        INIT_FCALL                                               'outer'
         14        DO_FCALL                                      0          
   17    15        INIT_DYNAMIC_CALL                                        !0
         16        SEND_VAL_EX                                              5
         17        SEND_VAL_EX                                              10
         18        DO_FCALL                                      0  $6      
         19        ECHO                                                     $6
   18    20        INIT_DYNAMIC_CALL                                        !0
         21        SEND_VAL_EX                                              5
         22        SEND_VAL_EX                                              10
         23        DO_FCALL                                      0  $7      
         24        ECHO                                                     $7
         25      > RETURN                                                   1

Function outer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86kk0
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%2F86kk0%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%2F86kk0%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/86kk0
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%2F86kk0%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.11 ms | 1402 KiB | 17 Q