3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Alice { protected const FOO = 'BLAH'; } class Wonderland extends Alice { protected const FOO = 'bar'; } var_dump(Wonderland::FOO); class Cat { protected final const FOO = 'bar'; } class Chesire extends Cat { protected const BAZ = 'too'; }
Output for 8.1.30 - 8.1.33, 8.2.21 - 8.2.29, 8.3.5 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught Error: Cannot access protected constant Wonderland::FOO in /in/rJG0V:11 Stack trace: #0 {main} thrown in /in/rJG0V on line 11
Process exited with code 255.
Output for 7.1.0 - 7.1.1
Fatal error: Cannot use 'final' as constant modifier in /in/rJG0V on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.15
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/rJG0V on line 4
Process exited with code 255.

preferences:
72.62 ms | 408 KiB | 5 Q