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; } } 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/CCh8J
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
          1        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget'
          2        SEND_VAL_EX                                              'asdF'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR_NO_REF_EX                                       $0
          5        DO_FCALL                                      0          
   43     6        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
          7        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget2'
          8        SEND_VAL_EX                                              'asdF'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR_NO_REF_EX                                       $2
         11        DO_FCALL                                      0          
   44    12        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cvar_dump'
         13        INIT_NS_FCALL_BY_NAME                                    'MyProject%5Cget3'
         14        SEND_VAL_EX                                              'asdF'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR_NO_REF_EX                                       $4
         17        DO_FCALL                                      0          
         18      > 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/CCh8J
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/CCh8J
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/CCh8J
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.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.73 ms | 1403 KiB | 18 Q