3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_func_get_arg($idx) { return isset(debug_backtrace()[1]['args'][$idx]) ? debug_backtrace()[1]['args'][$idx] : false; } function foo(&$arg) { $a = &func_get_arg(0); $a = 'bar'; } function bar(&$arg) { $a = &userland_func_get_arg(0); $a = 'bar'; } $foo = 'foo'; var_dump(foo($foo, 'bar')); var_dump($foo); $foo = 'foo'; var_dump(bar($foo, 'bar')); var_dump($foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/utd0V
function name:  (null)
number of ops:  23
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'foo'
    9     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'foo'
          3        SEND_REF                                                 !0
          4        SEND_VAL                                                 'bar'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   12     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   15    11        ASSIGN                                                   !0, 'foo'
   16    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'bar'
         14        SEND_REF                                                 !0
         15        SEND_VAL                                                 'bar'
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                                 
   18    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function userland_func_get_arg:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/utd0V
function name:  userland_func_get_arg
number of ops:  17
compiled vars:  !0 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $1      
          3        FETCH_DIM_IS                                     ~2      $1, 1
          4        FETCH_DIM_IS                                     ~3      ~2, 'args'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          6      > JMPZ                                                     ~4, ->14
          7    >   INIT_FCALL                                               'debug_backtrace'
          8        DO_ICALL                                         $5      
          9        FETCH_DIM_R                                      ~6      $5, 1
         10        FETCH_DIM_R                                      ~7      ~6, 'args'
         11        FETCH_DIM_R                                      ~8      ~7, !0
         12        QM_ASSIGN                                        ~9      ~8
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~9      <false>
         15    > > RETURN                                                   ~9
         16*     > RETURN                                                   null

End of function userland_func_get_arg

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

End of function foo

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

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.06 ms | 1403 KiB | 22 Q