3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public function func() { echo 'foo'; } } class Bar extends Foo { public function func() { echo 'bar'; } } $obj = new Bar(); $obj->func(); // returns of course 'bar' $parentClassString = get_parent_class($obj); $newObj = new $parentClassString; $newObj->func();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7DLt6
function name:  (null)
number of ops:  16
compiled vars:  !0 = $obj, !1 = $parentClassString, !2 = $newObj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   NEW                                                  $3      'Bar'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $3
   11     3        INIT_METHOD_CALL                                             !0, 'func'
          4        DO_FCALL                                          0          
   13     5        INIT_FCALL                                                   'get_parent_class'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !1, $7
   14     9        FETCH_CLASS                                       0  $9      !1
         10        NEW                                                  $10     $9
         11        DO_FCALL                                          0          
         12        ASSIGN                                                       !2, $10
   15    13        INIT_METHOD_CALL                                             !2, 'func'
         14        DO_FCALL                                          0          
         15      > RETURN                                                       1

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

End of function func

End of class Foo.

Class Bar:
Function func:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7DLt6
function name:  func
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                         'bar'
          1      > RETURN                                                       null

End of function func

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.35 ms | 2002 KiB | 14 Q