3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php final class MyType { const UNKNOWN = 0; const VALUE_ONE = 1; const VALUE_TWO = 2; const VALUE_THREE = 3; const VALUE_FOUR = 4; const VALUE_FIVE = 5; static public $__names = array( 0 => 'UNKNOWN', 1 => 'VALUE_ONE', 2 => 'VALUE_TWO', 3 => 'VALUE_THREE', 4 => 'VALUE_FOUR', 5 => 'VALUE_FIVE', ); } $test = new MyType(); echo MyType::$__names[count(MyType::$__names) - 1]; echo constant('MyType::' . MyType::$__names[count(MyType::$__names) - 1]); ?>
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
VALUE_FIVE5
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/jKXha on line 4
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_CLASS in /in/jKXha on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/jKXha on line 4
Process exited with code 255.