3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { const BAR = 42; } var_dump(constant('Foo::BAR')); var_dump(define('Foo::LOL', 37)); var_dump(Foo::LOL);
Output for 7.0.0 - 7.1.0
int(42) Warning: Class constants cannot be defined or redefined in /in/9W5f5 on line 6 bool(false) Fatal error: Uncaught Error: Undefined class constant 'LOL' in /in/9W5f5:7 Stack trace: #0 {main} thrown in /in/9W5f5 on line 7
Process exited with code 255.
Output for 5.2.13 - 5.2.17, 5.3.2 - 5.6.28
int(42) Warning: Class constants cannot be defined or redefined in /in/9W5f5 on line 6 bool(false) Fatal error: Undefined class constant 'LOL' in /in/9W5f5 on line 7
Process exited with code 255.
Output for 5.0.0 - 5.2.12, 5.3.0 - 5.3.1
int(42) bool(true) Fatal error: Undefined class constant 'LOL' in /in/9W5f5 on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9W5f5 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9W5f5 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/9W5f5 on line 3
Process exited with code 255.