3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace myns { $someclass = new \myotherns\someclass(); echo example($someclass); function example($class) { echo $class->nstest(); } } namespace myotherns { class someclass { function nstest() { $backtrace = debug_backtrace(); $caller = end($backtrace); $reflection = new \ReflectionFunction($caller['function']); return $reflection->getNamespaceName(); } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hIMRZ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $someclass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $1      'myotherns%5Csomeclass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
    4     3        INIT_NS_FCALL_BY_NAME                                    'myns%5Cexample'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   19     7      > RETURN                                                   1

Function myns%5Cexample:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hIMRZ
function name:  myns\example
number of ops:  5
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_METHOD_CALL                                         !0, 'nstest'
          2        DO_FCALL                                      0  $1      
          3        ECHO                                                     $1
    7     4      > RETURN                                                   null

End of function myns%5Cexample

Class myotherns\someclass:
Function nstest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hIMRZ
function name:  nstest
number of ops:  17
compiled vars:  !0 = $backtrace, !1 = $caller, !2 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_NS_FCALL_BY_NAME                                    'myotherns%5Cdebug_backtrace'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   14     3        INIT_NS_FCALL_BY_NAME                                    'myotherns%5Cend'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   15     7        NEW                                              $7      'ReflectionFunction'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_DIM_FUNC_ARG                               $8      !1, 'function'
         10        SEND_FUNC_ARG                                            $8
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $7
   16    13        INIT_METHOD_CALL                                         !2, 'getNamespaceName'
         14        DO_FCALL                                      0  $11     
         15      > RETURN                                                   $11
   17    16*     > RETURN                                                   null

End of function nstest

End of class myotherns\someclass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.58 ms | 1015 KiB | 16 Q