3v4l.org

run code in 500+ 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                              ~6      [0]
          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


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dPZlI
function name:  {closure:/in/dPZlI:11}
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 Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.78 ms | 1859 KiB | 14 Q