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) { $trace = debug_backtrace(); $args = $trace[1]['args']; call_user_func_array(array('Testme', $func_name), $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/1KURo
function name:  (null)
number of ops:  10
compiled vars:  !0 = $test, !1 = $testRef
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 2
   17     1        ASSIGN_REF                                               !1, !0
   18     2        INIT_STATIC_METHOD_CALL                                  'Invoker', 'invoke'
          3        SEND_VAL                                                 'foo'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
   19     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class Testme:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1KURo
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/1KURo
function name:  invoke
number of ops:  14
compiled vars:  !0 = $func_name, !1 = $trace, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !1, $3
   11     4        FETCH_DIM_R                                      ~5      !1, 1
          5        FETCH_DIM_R                                      ~6      ~5, 'args'
          6        ASSIGN                                                   !2, ~6
   12     7        INIT_ARRAY                                       ~8      'Testme'
          8        ADD_ARRAY_ELEMENT                                ~8      !0
          9        INIT_USER_CALL                                0          'call_user_func_array', ~8
         10        SEND_ARRAY                                               !2
         11        CHECK_UNDEF_ARGS                                         
         12        DO_FCALL                                      0          
   13    13      > RETURN                                                   null

End of function invoke

End of class Invoker.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.94 ms | 1396 KiB | 17 Q