3v4l.org

run code in 500+ PHP versions simultaneously
<?php class ParentClass { public static function whoAmI(): void { var_dump(static::class); } } class ChildClass extends ParentClass { public function byCallUserFunc(): void { call_user_func([\ParentClass::class, "whoAmI"]); } public function bySyntaxCall(): void { $className = ParentClass::class; $className::whoAmI(); } public function directCall(): void { ParentClass::whoAmI(); } public function callSelf(): void { self::whoAmI(); } } echo "ParentClass::whoAmI()" . PHP_EOL; ParentClass::whoAmI(); echo PHP_EOL . 'call_user_func([\ParentClass::class, "whoAmI"])' . PHP_EOL; call_user_func([\ParentClass::class, "whoAmI"]); $child = new ChildClass(); echo PHP_EOL . 'call_user_func([\ParentClass::class, "whoAmI"]) on ChildClass' . PHP_EOL; $child->byCallUserFunc(); echo PHP_EOL . '$className::whoAmI()' . PHP_EOL; $child->bySyntaxCall(); echo PHP_EOL . "ParentClass::whoAmI() on ChildClass" . PHP_EOL; $child->directCall(); echo PHP_EOL . "self::whoAmI()" . PHP_EOL; $child->callSelf();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  (null)
number of ops:  22
compiled vars:  !0 = $child
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   ECHO                                                         'ParentClass%3A%3AwhoAmI%28%29%0A'
   36     1        INIT_STATIC_METHOD_CALL                                      'ParentClass', 'whoAmI'
          2        DO_FCALL                                          0          
   38     3        ECHO                                                         '%0Acall_user_func%28%5B%5CParentClass%3A%3Aclass%2C+%22whoAmI%22%5D%29%0A'
   39     4        INIT_USER_CALL                                    0          'call_user_func', <array>
          5        DO_FCALL                                          0          
   41     6        NEW                                                  $3      'ChildClass'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !0, $3
   42     9        ECHO                                                         '%0Acall_user_func%28%5B%5CParentClass%3A%3Aclass%2C+%22whoAmI%22%5D%29+on+ChildClass%0A'
   43    10        INIT_METHOD_CALL                                             !0, 'byCallUserFunc'
         11        DO_FCALL                                          0          
   45    12        ECHO                                                         '%0A%24className%3A%3AwhoAmI%28%29%0A'
   46    13        INIT_METHOD_CALL                                             !0, 'bySyntaxCall'
         14        DO_FCALL                                          0          
   48    15        ECHO                                                         '%0AParentClass%3A%3AwhoAmI%28%29+on+ChildClass%0A'
   49    16        INIT_METHOD_CALL                                             !0, 'directCall'
         17        DO_FCALL                                          0          
   51    18        ECHO                                                         '%0Aself%3A%3AwhoAmI%28%29%0A'
   52    19        INIT_METHOD_CALL                                             !0, 'callSelf'
         20        DO_FCALL                                          0          
         21      > RETURN                                                       1

Class ParentClass:
Function whoami:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  whoAmI
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                                   'var_dump'
          1        FETCH_CLASS_NAME                                     ~0      
          2        SEND_VAL                                                     ~0
          3        DO_ICALL                                                     
    8     4      > RETURN                                                       null

End of function whoami

End of class ParentClass.

Class ChildClass:
Function bycalluserfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  byCallUserFunc
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   INIT_USER_CALL                                    0          'call_user_func', <array>
          1        DO_FCALL                                          0          
   16     2      > RETURN                                                       null

End of function bycalluserfunc

Function bysyntaxcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  bySyntaxCall
number of ops:  5
compiled vars:  !0 = $className
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                       !0, 'ParentClass'
   21     1        FETCH_CLASS                                       0  $2      !0
          2        INIT_STATIC_METHOD_CALL                                      $2, 'whoAmI'
          3        DO_FCALL                                          0          
   22     4      > RETURN                                                       null

End of function bysyntaxcall

Function directcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  directCall
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   INIT_STATIC_METHOD_CALL                                      'ParentClass', 'whoAmI'
          1        DO_FCALL                                          0          
   27     2      > RETURN                                                       null

End of function directcall

Function callself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  callSelf
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   INIT_STATIC_METHOD_CALL                                      'whoAmI'
          1        DO_FCALL                                          0          
   32     2      > RETURN                                                       null

End of function callself

Function whoami:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Vd6E
function name:  whoAmI
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                                   'var_dump'
          1        FETCH_CLASS_NAME                                     ~0      
          2        SEND_VAL                                                     ~0
          3        DO_ICALL                                                     
    8     4      > RETURN                                                       null

End of function whoami

End of class ChildClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
125.33 ms | 482 KiB | 8 Q