3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = 1; function foo($x) { return function () use ($x) { return $x; }; } $y = foo(100); $z = foo($x); var_dump($y(), $z());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uvAB1
function name:  (null)
number of ops:  18
compiled vars:  !0 = $x, !1 = $y, !2 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
   13     1        INIT_FCALL                                               'foo'
          2        SEND_VAL                                                 100
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   14     5        INIT_FCALL                                               'foo'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   16     9        INIT_FCALL                                               'var_dump'
         10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        INIT_DYNAMIC_CALL                                        !2
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

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

End of function foo

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

End of function %00%7Bclosure%7D%2Fin%2FuvAB1%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.74 ms | 1399 KiB | 17 Q