3v4l.org

run code in 300+ PHP versions simultaneously
<?php function closure() { $a = 0; return function () use (&$a) { return $a++; }; } $c = closure(); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c()); var_dump(function () { return $c; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iqAqh
function name:  (null)
number of ops:  33
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'closure'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   11     3        INIT_FCALL                                               'var_dump'
          4        INIT_DYNAMIC_CALL                                        !0
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   12     8        INIT_FCALL                                               'var_dump'
          9        INIT_DYNAMIC_CALL                                        !0
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                                 
   13    13        INIT_FCALL                                               'var_dump'
         14        INIT_DYNAMIC_CALL                                        !0
         15        DO_FCALL                                      0  $7      
         16        SEND_VAR                                                 $7
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'var_dump'
         19        INIT_DYNAMIC_CALL                                        !0
         20        DO_FCALL                                      0  $9      
         21        SEND_VAR                                                 $9
         22        DO_ICALL                                                 
   15    23        INIT_FCALL                                               'var_dump'
         24        INIT_DYNAMIC_CALL                                        !0
         25        DO_FCALL                                      0  $11     
         26        SEND_VAR                                                 $11
         27        DO_ICALL                                                 
   17    28        INIT_FCALL                                               'var_dump'
         29        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiqAqh%3A17%241'
   19    30        SEND_VAL                                                 ~13
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Function closure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iqAqh
function name:  closure
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 0
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiqAqh%3A5%240'
          2        BIND_LEXICAL                                             ~2, !0
    7     3      > RETURN                                                   ~2
    8     4*     > RETURN                                                   null

End of function closure

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

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

Function %00%7Bclosure%7D%2Fin%2FiqAqh%3A17%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iqAqh
function name:  {closure}
number of ops:  2
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   !0
   19     1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FiqAqh%3A17%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.85 ms | 1403 KiB | 16 Q