3v4l.org

run code in 300+ PHP versions simultaneously
<?php class First { public function test1() { echo get_called_class(); } public function test2() { print_r(debug_backtrace()); } public function test3() { echo get_class($this); } public function test4() { echo __CLASS__; } public static function test5() { echo get_called_class(); } } function class_alias_kinda($original, $alias) { eval("class $alias extends $original {}"); } class_alias_kinda('First', 'Second'); $aliased = new Second(); $aliased->test1(); // Second $aliased->test2(); // array( 0 => array( ... [object] => Second Object, ... ) ) $aliased->test3(); // Second $aliased->test4(); // First (this is expected) Second::test5(); // Second
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vfYn2
function name:  (null)
number of ops:  18
compiled vars:  !0 = $aliased
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'class_alias_kinda'
          1        SEND_VAL                                                 'First'
          2        SEND_VAL                                                 'Second'
          3        DO_FCALL                                      0          
   16     4        NEW                                              $2      'Second'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
   17     7        INIT_METHOD_CALL                                         !0, 'test1'
          8        DO_FCALL                                      0          
   18     9        INIT_METHOD_CALL                                         !0, 'test2'
         10        DO_FCALL                                      0          
   19    11        INIT_METHOD_CALL                                         !0, 'test3'
         12        DO_FCALL                                      0          
   20    13        INIT_METHOD_CALL                                         !0, 'test4'
         14        DO_FCALL                                      0          
   21    15        INIT_STATIC_METHOD_CALL                                  'Second', 'test5'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Function class_alias_kinda:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vfYn2
function name:  class_alias_kinda
number of ops:  9
compiled vars:  !0 = $original, !1 = $alias
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ROPE_INIT                                     5  ~3      'class+'
          3        ROPE_ADD                                      1  ~3      ~3, !1
          4        ROPE_ADD                                      2  ~3      ~3, '+extends+'
          5        ROPE_ADD                                      3  ~3      ~3, !0
          6        ROPE_END                                      4  ~2      ~3, '+%7B%7D'
          7        INCLUDE_OR_EVAL                                          ~2, EVAL
   13     8      > RETURN                                                   null

End of function class_alias_kinda

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

End of function test1

Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vfYn2
function name:  test2
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   null

End of function test2

Function test3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vfYn2
function name:  test3
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        ECHO                                                     ~1
          3      > RETURN                                                   null

End of function test3

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

End of function test4

Function test5:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vfYn2
function name:  test5
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   GET_CALLED_CLASS                                 ~0      
          1        ECHO                                                     ~0
          2      > RETURN                                                   null

End of function test5

End of class First.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.03 ms | 1407 KiB | 18 Q