3v4l.org

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

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

End of function foo

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

End of function %00%7Bclosure%7D%2Fin%2FoUCJ7%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.89 ms | 1403 KiB | 17 Q