3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Testme { public static function foo(&$ref) { $ref = 1; } } class Invoker { public static function invoke($func_name) { $args = func_get_args_byref(); $ref = &array_slice($args,1); call_user_func_array(array('Testme', $func_name), $ref); } } function func_get_args_byref() { $trace = debug_backtrace(); return $trace[1]['args']; } $test = 2; $testRef = &$test; Invoker::invoke('foo', $testRef); var_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N2Jd7
function name:  (null)
number of ops:  10
compiled vars:  !0 = $test, !1 = $testRef
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, 2
   23     1        ASSIGN_REF                                               !1, !0
   24     2        INIT_STATIC_METHOD_CALL                                  'Invoker', 'invoke'
          3        SEND_VAL                                                 'foo'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
   25     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function func_get_args_byref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N2Jd7
function name:  func_get_args_byref
number of ops:  7
compiled vars:  !0 = $trace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'debug_backtrace'
          1        DO_ICALL                                         $1      
          2        ASSIGN                                                   !0, $1
   18     3        FETCH_DIM_R                                      ~3      !0, 1
          4        FETCH_DIM_R                                      ~4      ~3, 'args'
          5      > RETURN                                                   ~4
   19     6*     > RETURN                                                   null

End of function func_get_args_byref

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

End of function foo

End of class Testme.

Class Invoker:
Function invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N2Jd7
function name:  invoke
number of ops:  16
compiled vars:  !0 = $func_name, !1 = $args, !2 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL_BY_NAME                                       'func_get_args_byref'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   11     4        INIT_FCALL                                               'array_slice'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $5      
          8        ASSIGN_REF                                               !2, $5
   12     9        INIT_ARRAY                                       ~7      'Testme'
         10        ADD_ARRAY_ELEMENT                                ~7      !0
         11        INIT_USER_CALL                                0          'call_user_func_array', ~7
         12        SEND_ARRAY                                               !2
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      0          
   13    15      > RETURN                                                   null

End of function invoke

End of class Invoker.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.37 ms | 1392 KiB | 19 Q