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 5.5.24 - 5.5.30, 5.6.8 - 5.6.16, 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '=' in /in/GOXsi on line 70
Process exited with code 255.

preferences:
163.98 ms | 1395 KiB | 25 Q