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() { return func_get_arg(0); } function bar() { return userland_func_get_arg(0); } var_dump(foo('foo', 'bar')); var_dump(bar('foo', 'bar'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vcYso
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'foo'
          2        SEND_VAL                                                 'foo'
          3        SEND_VAL                                                 'bar'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
    9     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'bar'
          9        SEND_VAL                                                 'foo'
         10        SEND_VAL                                                 'bar'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
         14      > 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/vcYso
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/vcYso
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'func_get_arg'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                         $0      
          3      > RETURN                                                   $0
          4*     > 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/vcYso
function name:  bar
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'userland_func_get_arg'
          1        SEND_VAL                                                 0
          2        DO_FCALL                                      0  $0      
          3      > RETURN                                                   $0
          4*     > RETURN                                                   null

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.21 ms | 1403 KiB | 22 Q