3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { public function sayHi () { echo "hi"; } } class Caller { private $_controller, $_action; public function __construct ($cont, $action) { $this->_controller = $cont; $this->_action = $action; } public function __toString() { return (string)$this->_action; } public function run () { $controller = new $this->_controller; if (is_callable(array($controller, $this->_action))) { $controller->{$this->_action}; } } } $caller = new Caller ('Example', 'sayHi'); $caller->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I99j
function name:  (null)
number of ops:  9
compiled vars:  !0 = $caller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'caller'
   30     1        NEW                                              $1      'Caller'
          2        SEND_VAL_EX                                              'Example'
          3        SEND_VAL_EX                                              'sayHi'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   31     6        INIT_METHOD_CALL                                         !0, 'run'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Class Example:
Function sayhi:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I99j
function name:  sayHi
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'hi'
    6     1      > RETURN                                                   null

End of function sayhi

End of class Example.

Class Caller:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I99j
function name:  __construct
number of ops:  7
compiled vars:  !0 = $cont, !1 = $action
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        ASSIGN_OBJ                                               '_controller'
          3        OP_DATA                                                  !0
   15     4        ASSIGN_OBJ                                               '_action'
          5        OP_DATA                                                  !1
   16     6      > RETURN                                                   null

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I99j
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      '_action'
          1        CAST                                          6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   20     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/4I99j
function name:  run
number of ops:  16
compiled vars:  !0 = $controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_OBJ_R                                      ~1      '_controller'
          1        FETCH_CLASS                                   0  $2      ~1
          2        NEW                                              $3      $2
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   24     5        INIT_FCALL                                               'is_callable'
          6        INIT_ARRAY                                       ~6      !0
          7        FETCH_OBJ_R                                      ~7      '_action'
          8        ADD_ARRAY_ELEMENT                                ~6      ~7
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                         $8      
         11      > JMPZ                                                     $8, ->15
   25    12    >   FETCH_OBJ_R                                      ~9      '_action'
         13        FETCH_OBJ_R                                      ~10     !0, ~9
         14        FREE                                                     ~10
   27    15    > > RETURN                                                   null

End of function run

End of class Caller.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.6 ms | 1400 KiB | 15 Q