3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo\Bar { class Baz {} } namespace { function byReflection($obj) { $r = new ReflectionObject($obj); return $r->getName(); } function byString($obj) { $class = get_class($obj); return substr($class, strrpos($class, '\\')); } $a = new StdClass; $b = new Foo\Bar\Baz; var_dump(byReflection($a), byString($a), byReflection($b), byString($b)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B4hJX
function name:  (null)
number of ops:  25
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $2      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   20     3        NEW                                              $5      'Foo%5CBar%5CBaz'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   22     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'byreflection'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $8      
         10        SEND_VAR                                                 $8
         11        INIT_FCALL                                               'bystring'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        INIT_FCALL                                               'byreflection'
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $10     
         18        SEND_VAR                                                 $10
         19        INIT_FCALL                                               'bystring'
         20        SEND_VAR                                                 !1
         21        DO_FCALL                                      0  $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                                 
   24    24      > RETURN                                                   1

Function byreflection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B4hJX
function name:  byReflection
number of ops:  9
compiled vars:  !0 = $obj, !1 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        NEW                                              $2      'ReflectionObject'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
   11     5        INIT_METHOD_CALL                                         !1, 'getName'
          6        DO_FCALL                                      0  $5      
          7      > RETURN                                                   $5
   12     8*     > RETURN                                                   null

End of function byreflection

Function bystring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B4hJX
function name:  byString
number of ops:  13
compiled vars:  !0 = $obj, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        GET_CLASS                                        ~2      !0
          2        ASSIGN                                                   !1, ~2
   16     3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !1
          5        INIT_FCALL                                               'strrpos'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 '%5C'
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
   17    12*     > RETURN                                                   null

End of function bystring

Class Foo\Bar\Baz: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.59 ms | 1403 KiB | 23 Q