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'};
Output for 8.3.0 - 8.3.31, 8.4.1 - 8.4.14, 8.4.16 - 8.4.22, 8.5.0 - 8.5.7
3 Fatal error: Uncaught Error: Undefined constant X::B in /in/QKvnA:18 Stack trace: #0 {main} thrown in /in/QKvnA on line 18
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
Process exited with code 127.
Output for 8.1.34, 8.2.0 - 8.2.30
Parse error: syntax error, unexpected token ";", expecting "(" in /in/QKvnA on line 15
Process exited with code 255.

preferences:
60.26 ms | 870 KiB | 4 Q