3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public static function className() { if (!function_exists('get_called_class')) { $t = debug_backtrace(); print_r($t); return; $t = $t[0]; if (isset($t['object']) && $t['object'] instanceof $t['class']) return get_class($t['object']); return false; return __CLASS__; } return get_called_class(); } } class Dupa extends Test { } echo Test::className(); echo "\n"; echo Dupa::className();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QJMNT
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_STATIC_METHOD_CALL                                  'Test', 'className'
          1        DO_FCALL                                      0  $0      
          2        ECHO                                                     $0
   30     3        ECHO                                                     '%0A'
   31     4        INIT_STATIC_METHOD_CALL                                  'Dupa', 'className'
          5        DO_FCALL                                      0  $1      
          6        ECHO                                                     $1
          7      > RETURN                                                   1

Class Test:
Function classname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 27
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QJMNT
function name:  className
number of ops:  30
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'get_called_class'
          2        DO_ICALL                                         $1      
          3        BOOL_NOT                                         ~2      $1
          4      > JMPZ                                                     ~2, ->27
    8     5    >   INIT_FCALL                                               'debug_backtrace'
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
    9     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   10    11      > RETURN                                                   null
   12    12*       FETCH_DIM_R                                      ~6      !0, 0
         13*       ASSIGN                                                   !0, ~6
   13    14*       ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !0, 'object'
         15*       JMPZ_EX                                          ~8      ~8, ->21
         16*       FETCH_DIM_R                                      ~9      !0, 'object'
         17*       FETCH_DIM_R                                      ~10     !0, 'class'
         18*       FETCH_CLASS                                   0  $11     ~10
         19*       INSTANCEOF                                       ~12     ~9, $11
         20*       BOOL                                             ~8      ~12
         21*       JMPZ                                                     ~8, ->25
   14    22*       FETCH_DIM_R                                      ~13     !0, 'object'
         23*       GET_CLASS                                        ~14     ~13
         24*       RETURN                                                   ~14
   15    25*       RETURN                                                   <false>
   17    26*       RETURN                                                   'Test'
   20    27    >   GET_CALLED_CLASS                                 ~15     
         28      > RETURN                                                   ~15
   21    29*     > RETURN                                                   null

End of function classname

End of class Test.

Class Dupa:
Function classname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 27
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QJMNT
function name:  className
number of ops:  30
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'get_called_class'
          2        DO_ICALL                                         $1      
          3        BOOL_NOT                                         ~2      $1
          4      > JMPZ                                                     ~2, ->27
    8     5    >   INIT_FCALL                                               'debug_backtrace'
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
    9     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   10    11      > RETURN                                                   null
   12    12*       FETCH_DIM_R                                      ~6      !0, 0
         13*       ASSIGN                                                   !0, ~6
   13    14*       ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !0, 'object'
         15*       JMPZ_EX                                          ~8      ~8, ->21
         16*       FETCH_DIM_R                                      ~9      !0, 'object'
         17*       FETCH_DIM_R                                      ~10     !0, 'class'
         18*       FETCH_CLASS                                   0  $11     ~10
         19*       INSTANCEOF                                       ~12     ~9, $11
         20*       BOOL                                             ~8      ~12
         21*       JMPZ                                                     ~8, ->25
   14    22*       FETCH_DIM_R                                      ~13     !0, 'object'
         23*       GET_CLASS                                        ~14     ~13
         24*       RETURN                                                   ~14
   15    25*       RETURN                                                   <false>
   17    26*       RETURN                                                   'Test'
   20    27    >   GET_CALLED_CLASS                                 ~15     
         28      > RETURN                                                   ~15
   21    29*     > RETURN                                                   null

End of function classname

End of class Dupa.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.94 ms | 1400 KiB | 19 Q