3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { const MY_CONST = 'This is my const'; } class B { private $property; public function __construct(A $a) { $this->property = $a; echo $a::MY_CONST."<br />"; // works (1) echo A::MY_CONST."<br />"; // works (2) $obj = $this->property; echo $obj::MY_CONST."<br />"; // works (3) echo( $this->__get('property')::MY_CONST ); // doesn't work (4) } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gv4KY
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E > > RETURN                                                   1

Class A: [no user functions]
Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gv4KY
function name:  __construct
number of ops:  21
compiled vars:  !0 = $a, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN_OBJ                                               'property'
          2        OP_DATA                                                  !0
   14     3        FETCH_CLASS                                   0  $3      !0
          4        FETCH_CLASS_CONSTANT                             ~4      $3, 'MY_CONST'
          5        CONCAT                                           ~5      ~4, '%3Cbr+%2F%3E'
          6        ECHO                                                     ~5
   16     7        ECHO                                                     'This+is+my+const%3Cbr+%2F%3E'
   18     8        FETCH_OBJ_R                                      ~6      'property'
          9        ASSIGN                                                   !1, ~6
   20    10        FETCH_CLASS                                   0  $8      !1
         11        FETCH_CLASS_CONSTANT                             ~9      $8, 'MY_CONST'
         12        CONCAT                                           ~10     ~9, '%3Cbr+%2F%3E'
         13        ECHO                                                     ~10
   22    14        INIT_METHOD_CALL                                         '__get'
         15        SEND_VAL_EX                                              'property'
         16        DO_FCALL                                      0  $11     
         17        FETCH_CLASS                                   0  $12     $11
         18        FETCH_CLASS_CONSTANT                             ~13     $12, 'MY_CONST'
         19        ECHO                                                     ~13
   23    20      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.11 ms | 1394 KiB | 13 Q