3v4l.org

run code in 500+ PHP versions simultaneously
<?php function test(){ $sum = 0; return function ($i) use($sum) { $sum += $i; return $sum; }; } $myfunc = test(); for($i = 0; $i < 5; $i++){ echo $myfunc($i) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
Branch analysis from position: 5
filename:       /in/YSTW6
function name:  (null)
number of ops:  14
compiled vars:  !0 = $myfunc, !1 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                                   'test'
          1        DO_FCALL                                          0  $2      
          2        ASSIGN                                                       !0, $2
   14     3        ASSIGN                                                       !1, 0
          4      > JMP                                                          ->11
   15     5    >   INIT_DYNAMIC_CALL                                            !0
          6        SEND_VAR_EX                                                  !1
          7        DO_FCALL                                          0  $5      
          8        CONCAT                                               ~6      $5, '%0A'
          9        ECHO                                                         ~6
   14    10        PRE_INC                                                      !1
         11    >   IS_SMALLER                                                   !1, 5
         12      > JMPNZ                                                        ~8, ->5
   16    13    > > RETURN                                                       1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YSTW6
function name:  test
number of ops:  5
compiled vars:  !0 = $sum
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, 0
    6     1        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          2        BIND_LEXICAL                                                 ~2, !0
    9     3      > RETURN                                                       ~2
   10     4*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YSTW6
function name:  {closure:test():6}
number of ops:  5
compiled vars:  !0 = $i, !1 = $sum
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
    7     2        ASSIGN_OP                                         1          !1, !0
    8     3      > RETURN                                                       !1
    9     4*     > RETURN                                                       null

End of Dynamic Function 0

End of function test

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
148.3 ms | 1941 KiB | 14 Q