3v4l.org

run code in 300+ PHP versions simultaneously
<?php use ReflectionClass; class Language { const DUTCH = 1; private static $languages_values; public static function getConstName($value) { if (!isset(self::$languages_values[$value])) { thow new \Exception('de value bestaat niet!'); } return self::$languages_values[$value]; } public static function init() { static $initialized = false; if ( ! $initialized) { $ref_class = new ReflectionClass(self::class); self::$languages_values = array_flip($ref_class->getConstants()); $initialized = true; } } } // ja, dit zet je in het zelfde bestand Language::init();
Output for 5.4.0 - 5.4.28
Warning: The use statement with non-compound name 'ReflectionClass' has no effect in /in/nEMqB on line 3 Parse error: syntax error, unexpected 'new' (T_NEW) in /in/nEMqB on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Warning: The use statement with non-compound name 'ReflectionClass' has no effect in /in/nEMqB on line 3 Parse error: syntax error, unexpected T_NEW in /in/nEMqB on line 13
Process exited with code 255.

preferences:
185.98 ms | 1395 KiB | 65 Q