3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { const BAR = 42; } var_dump(Foo::BAR); var_dump(constant('Foo::BAR')); var_dump(define('Foo::BAR', 37)); var_dump(Foo::BAR); var_dump(constant('Foo::BAR'));
based on 9W5f5
Output for 5.2.13 - 5.2.17, 5.3.2 - 5.6.28, 7.0.0 - 7.1.0
int(42) int(42) Warning: Class constants cannot be defined or redefined in /in/3IJ9d on line 7 bool(false) int(42) int(42)
Output for 5.0.0 - 5.2.12, 5.3.0 - 5.3.1, hhvm-3.10.0 - 3.12.0
int(42) int(42) bool(true) int(42) int(42)
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/3IJ9d 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/3IJ9d 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/3IJ9d on line 3
Process exited with code 255.