3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyClass { const CONSTANT = 'constant value'; function showConstant() { echo self::CONSTANT . "\n"; } } echo MyClass::CONSTANT . "\n"; $classname = "MyClass"; echo $classname::CONSTANT . "\n"; // As of PHP 5.3.0 class B { function __construct() { $this->myclass = new MyClass(); $this->myclass->showConstant(); echo $this->myclass::CONSTANT; } } $b = new B ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YmaHq
function name:  (null)
number of ops:  10
compiled vars:  !0 = $classname, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ECHO                                                         'constant+value%0A'
   13     1        ASSIGN                                                       !0, 'MyClass'
   14     2        FETCH_CLASS                                       0  $3      !0
          3        FETCH_CLASS_CONSTANT                                 ~4      $3, 'CONSTANT'
          4        CONCAT                                               ~5      ~4, '%0A'
          5        ECHO                                                         ~5
   26     6        NEW                                                  $6      'B'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $6
   27     9      > RETURN                                                       1

Class MyClass:
Function showconstant:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YmaHq
function name:  showConstant
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                         'constant+value%0A'
    8     1      > RETURN                                                       null

End of function showconstant

End of class MyClass.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YmaHq
function name:  __construct
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   NEW                                                  $1      'MyClass'
          1        DO_FCALL                                          0          
          2        ASSIGN_OBJ                                                   'myclass'
          3        OP_DATA                                                      $1
   21     4        FETCH_OBJ_R                                          ~3      'myclass'
          5        INIT_METHOD_CALL                                             ~3, 'showConstant'
          6        DO_FCALL                                          0          
   22     7        FETCH_OBJ_R                                          ~5      'myclass'
          8        FETCH_CLASS                                       0  $6      ~5
          9        FETCH_CLASS_CONSTANT                                 ~7      $6, 'CONSTANT'
         10        ECHO                                                         ~7
   23    11      > RETURN                                                       null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.66 ms | 2724 KiB | 13 Q