3v4l.org

run code in 300+ PHP versions simultaneously
<?php // investigating closures in closures $f = function() { static $p = 'p'; return static function() { return static::$p; }; }; $g = static function() { static $p = 'p'; return static function() { return static::$p; }; }; $h = function() { static $p = 'p'; return function() { return static::$p; }; }; $f_inner = $f(); $g_inner = $g(); $h_inner = $h(); var_dump($f_inner(), $g_inner(), $h_inner());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  (null)
number of ops:  27
compiled vars:  !0 = $f, !1 = $g, !2 = $h, !3 = $f_inner, !4 = $g_inner, !5 = $h_inner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDa6t0%3A3%240'
          1        ASSIGN                                                   !0, ~6
   11     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDa6t0%3A11%242'
          3        ASSIGN                                                   !1, ~8
   19     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDa6t0%3A19%244'
          5        ASSIGN                                                   !2, ~10
   26     6        INIT_DYNAMIC_CALL                                        !0
          7        DO_FCALL                                      0  $12     
          8        ASSIGN                                                   !3, $12
   27     9        INIT_DYNAMIC_CALL                                        !1
         10        DO_FCALL                                      0  $14     
         11        ASSIGN                                                   !4, $14
   28    12        INIT_DYNAMIC_CALL                                        !2
         13        DO_FCALL                                      0  $16     
         14        ASSIGN                                                   !5, $16
   29    15        INIT_FCALL                                               'var_dump'
         16        INIT_DYNAMIC_CALL                                        !3
         17        DO_FCALL                                      0  $18     
         18        SEND_VAR                                                 $18
         19        INIT_DYNAMIC_CALL                                        !4
         20        DO_FCALL                                      0  $19     
         21        SEND_VAR                                                 $19
         22        INIT_DYNAMIC_CALL                                        !5
         23        DO_FCALL                                      0  $20     
         24        SEND_VAR                                                 $20
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A3%240

Function %00%7Bclosure%7D%2Fin%2FDa6t0%3A5%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'p'
          1      > RETURN                                                   ~0
    7     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A5%241

Function %00%7Bclosure%7D%2Fin%2FDa6t0%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   BIND_STATIC                                              !0
   13     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDa6t0%3A13%243'
   15     2      > RETURN                                                   ~1
   16     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A11%242

Function %00%7Bclosure%7D%2Fin%2FDa6t0%3A13%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'p'
          1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A13%243

Function %00%7Bclosure%7D%2Fin%2FDa6t0%3A19%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   BIND_STATIC                                              !0
   21     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDa6t0%3A21%245'
   23     2      > RETURN                                                   ~1
   24     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A19%244

Function %00%7Bclosure%7D%2Fin%2FDa6t0%3A21%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Da6t0
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'p'
          1      > RETURN                                                   ~0
   23     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDa6t0%3A21%245

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.23 ms | 1400 KiB | 15 Q