3v4l.org

run code in 300+ PHP versions simultaneously
<?php // plain variable $a = 42; // array containing a reference $b = [ 'a' => &$a ]; // capture the array by-value $f = function() use($b) { // update the reference from inside the closure $b['a'] = 69; }; // call it $f(); // observe that both the array and the plain variable now have the new value var_dump($a, $b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dPZlI
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 42
    7     1        INIT_ARRAY                                       ~4      !0, 'a'
    6     2        ASSIGN                                                   !1, ~4
   11     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdPZlI%3A11%240'
          4        BIND_LEXICAL                                             ~6, !1
          5        ASSIGN                                                   !2, ~6
   17     6        INIT_DYNAMIC_CALL                                        !2
          7        DO_FCALL                                      0          
   19     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdPZlI%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dPZlI
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   BIND_STATIC                                              !0
   13     1        ASSIGN_DIM                                               !0, 'a'
          2        OP_DATA                                                  69
   14     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdPZlI%3A11%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.48 ms | 1395 KiB | 15 Q