3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*namespace MyProject; use blah\blah as mine; // see "Using namespaces: importing/aliasing" blah\mine(); // calls function MyProject\blah\mine() namespace\blah\mine(); // calls function MyProject\blah\mine() namespace\func(); // calls function MyProject\func() namespace\sub\func(); // calls function MyProject\sub\func() namespace\cname::method(); // calls static method "method" of class MyProject\cname $a = new namespace\sub\cname(); // instantiates object of class MyProject\sub\cname $b = namespace\CONSTANT; // assigns value of constant MyProject\CONSTANT to $b ?>*/ namespace MyProject; class Asdf { function get($classname) { $a = __NAMESPACE__ . '\\' . $classname; return new $a; return new self; return new static; } function get2($classname) { return new self; } function get3($classname) { return new static; } } class asdf {} var_dump(get('asdF')); var_dump(get2('asdF')); var_dump(get3('asdF'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPHaD
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   DECLARE_CLASS                                            'myproject%5Casdf'
   42     1        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
          2        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget'
          3        SEND_VAL_EX                                              'asdF'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR_NO_REF_EX                                       $0
          6        DO_FCALL                                      0          
   43     7        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
          8        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget2'
          9        SEND_VAL_EX                                              'asdF'
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR_NO_REF_EX                                       $2
         12        DO_FCALL                                      0          
   44    13        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
         14        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget3'
         15        SEND_VAL_EX                                              'asdF'
         16        DO_FCALL                                      0  $4      
         17        SEND_VAR_NO_REF_EX                                       $4
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Class MyProject\Asdf:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPHaD
function name:  get
number of ops:  14
compiled vars:  !0 = $classname, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        CONCAT                                           ~2      'MyProject%5C', !0
          2        ASSIGN                                                   !1, ~2
   24     3        FETCH_CLASS                                   0  $4      !1
          4        NEW                                              $5      $4
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $5
   25     7*       NEW                          self                $7      
          8*       DO_FCALL                                      0          
          9*       RETURN                                                   $7
   26    10*       NEW                          static              $9      
         11*       DO_FCALL                                      0          
         12*       RETURN                                                   $9
   27    13*     > RETURN                                                   null

End of function get

Function get2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPHaD
function name:  get2
number of ops:  5
compiled vars:  !0 = $classname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   31     1        NEW                          self                $1      
          2        DO_FCALL                                      0          
          3      > RETURN                                                   $1
   33     4*     > RETURN                                                   null

End of function get2

Function get3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPHaD
function name:  get3
number of ops:  5
compiled vars:  !0 = $classname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   37     1        NEW                          static              $1      
          2        DO_FCALL                                      0          
          3      > RETURN                                                   $1
   38     4*     > RETURN                                                   null

End of function get3

End of class MyProject\Asdf.

Class MyProject\asdf: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.5 ms | 1403 KiB | 18 Q