3v4l.org

run code in 300+ PHP versions simultaneously
<?php function byref( &$arg ) { $arg = 'abc'; } function bar($a) { $x = new Exception(); $trace = $x->getTrace(); foreach ( $trace as $frame ) { if ( empty( $frame['args'] ) ) { continue; } foreach ( $frame['args'] as $key => $arg ) { if ( is_array( $arg ) ) { // array_walk_recursive( $arg, 'byref' ); // same issue when doing it manually: foreach ( $arg as &$foo ) { $foo = 'xyz'; } unset( $foo ); } } } } $b = array( 'X', 'Y' ); foreach ( $b as &$value ) { bar( $b ); var_dump( $value ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/1SGGd
function name:  (null)
number of ops:  12
compiled vars:  !0 = $b, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   30     1      > FE_RESET_RW                                      $3      !0, ->10
          2    > > FE_FETCH_RW                                              $3, !1, ->10
   31     3    >   INIT_FCALL                                               'bar'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
   32     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   30     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   33    11      > RETURN                                                   1

Function byref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1SGGd
function name:  byref
number of ops:  3
compiled vars:  !0 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !0, 'abc'
    5     2      > RETURN                                                   null

End of function byref

Function bar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 125) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 126) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 22
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/1SGGd
function name:  bar
number of ops:  29
compiled vars:  !0 = $a, !1 = $x, !2 = $trace, !3 = $frame, !4 = $arg, !5 = $key, !6 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        NEW                                              $7      'Exception'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    9     4        INIT_METHOD_CALL                                         !1, 'getTrace'
          5        DO_FCALL                                      0  $10     
          6        ASSIGN                                                   !2, $10
   11     7      > FE_RESET_R                                       $12     !2, ->27
          8    > > FE_FETCH_R                                               $12, !3, ->27
   12     9    >   ISSET_ISEMPTY_DIM_OBJ                         1          !3, 'args'
         10      > JMPZ                                                     ~13, ->12
   13    11    > > JMP                                                      ->8
   16    12    >   FETCH_DIM_R                                      ~14     !3, 'args'
         13      > FE_RESET_R                                       $15     ~14, ->25
         14    > > FE_FETCH_R                                       ~16     $15, !4, ->25
         15    >   ASSIGN                                                   !5, ~16
   17    16        TYPE_CHECK                                  128          !4
         17      > JMPZ                                                     ~18, ->24
   20    18    > > FE_RESET_RW                                      $19     !4, ->22
         19    > > FE_FETCH_RW                                              $19, !6, ->22
   21    20    >   ASSIGN                                                   !6, 'xyz'
   20    21      > JMP                                                      ->19
         22    >   FE_FREE                                                  $19
   23    23        UNSET_CV                                                 !6
   16    24    > > JMP                                                      ->14
         25    >   FE_FREE                                                  $15
   11    26      > JMP                                                      ->8
         27    >   FE_FREE                                                  $12
   27    28      > RETURN                                                   null

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.18 ms | 1009 KiB | 15 Q