3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class WorkUnitDataType { const NoneType = 0; const ArrayType = 1; const JsonType = 2; const UrlType = 3; const FileType = 4; private $value; private $name; protected function __construct($input) { if (is_int($input)) { $this->setByValue($input); } else if (is_string($input)) { $this->setByName($input); } } protected function setByValue($value) { if (is_int($value)) { $this->value = $value; $this->name = WorkUnitDataType::toString($value); } } protected function setByName($name) { if (is_) $this->value = WorkUnitDataType::toString($name); $this->name = $name; } public static function toString($const) { $class = new ReflectionClass('WorkUnitDataType'); $constants = $class->getConstants(); foreach ($constants as $name => $value) { if ($value == $const) { return $name; } } return Null; } public static function toValue($text) { $class = new ReflectionClass('WorkUnitDataType'); $constants = $class->getConstants(); foreach ($constants as $name => $value) { if ($name == $text) { return $value; } } return -1; } } class NoneType extends WorkUnitDataType { public function __construct() { parent::__construct(get_class($this)); } } $a = new NoneType(); var_dump($a);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "is_" in /in/iLTUI:31 Stack trace: #0 /in/iLTUI(17): WorkUnitDataType->setByName('NoneType') #1 /in/iLTUI(65): WorkUnitDataType->__construct('NoneType') #2 /in/iLTUI(70): NoneType->__construct() #3 {main} thrown in /in/iLTUI on line 31
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant is_ - assumed 'is_' (this will throw an Error in a future version of PHP) in /in/iLTUI on line 31 object(NoneType)#1 (2) { ["value":"WorkUnitDataType":private]=> string(8) "NoneType" ["name":"WorkUnitDataType":private]=> string(8) "NoneType" }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Notice: Use of undefined constant is_ - assumed 'is_' in /in/iLTUI on line 31 object(NoneType)#1 (2) { ["value":"WorkUnitDataType":private]=> string(8) "NoneType" ["name":"WorkUnitDataType":private]=> string(8) "NoneType" }

preferences:
142.81 ms | 402 KiB | 183 Q