3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Enum { private static $cache = []; public static function __callStatic($name, $params) { $className = get_called_class(); if(!isset(self::$cache[$name])) { self::$cache[$name] = new $className($className::$$name); } return self::$cache[$name]; } } class Operator { public const A = 22; private const EQUALS = ['=']; private $symbol; private function __const(string $symbol) { $this->symbol = $symbol; } } $a = "A"; var_dump(Operator::$a) var_dump(Enum::EQUALS());
based on KKkL6
Output for 7.1.0 - 7.1.7
Parse error: syntax error, unexpected 'var_dump' (T_STRING) in /in/iK81l on line 27
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/iK81l on line 17
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/iK81l:17 Stack trace: #0 {main}
Process exited with code 255.