3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { const A = null; } // ?? works with class constants echo X::A ?? 3; // parse error, invalid syntax //echo X::{A} ?? 3; // quotes are needed, or a global constant const A = 'A'; echo X::{A}; // @ does not hide undefined constants echo @X::{'B'};
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QKvnA
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   COALESCE                                             ~0      null
          1        QM_ASSIGN                                            ~0      3
          2        ECHO                                                         ~0
   14     3        DECLARE_CONST                                                'A', 'A'
   15     4        FETCH_CONSTANT                                       ~1      'A'
          5        FETCH_CLASS_CONSTANT                                 ~2      'X', ~1
          6        ECHO                                                         ~2
   18     7        BEGIN_SILENCE                                        ~3      
          8        FETCH_CLASS_CONSTANT                                 ~4      'X', 'B'
          9        END_SILENCE                                                  ~3
         10        ECHO                                                         ~4
         11      > RETURN                                                       1

Class X: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.45 ms | 1487 KiB | 13 Q