3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_func_num_args() { return count(debug_backtrace()[1]['args'][$idx]); } function foo() { return func_num_args(); } function bar() { return userland_func_num_args(); } 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/PkHEN
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_num_args:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PkHEN
function name:  userland_func_num_args
number of ops:  8
compiled vars:  !0 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $1      
          2        FETCH_DIM_R                                      ~2      $1, 1
          3        FETCH_DIM_R                                      ~3      ~2, 'args'
          4        FETCH_DIM_R                                      ~4      ~3, !0
          5        COUNT                                            ~5      ~4
          6      > RETURN                                                   ~5
          7*     > RETURN                                                   null

End of function userland_func_num_args

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PkHEN
function name:  foo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FUNC_NUM_ARGS                                    ~0      
          1      > RETURN                                                   ~0
          2*     > 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/PkHEN
function name:  bar
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'userland_func_num_args'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169 ms | 1390 KiB | 20 Q