3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass { private $val = 1; public function getVal() { return $this->val; } } trait MyTrait { public function cry() { echo "nya"; } } interface MyInterface { public function say(); } abstract MyAbstract { abstract public function shout(); } function check($class_name) { echo "================ ", $class_name, " ================= \n"; $h = new \ReflectionClass($class_name); echo "abstract? ", $h->isAbstract() ? "true" : "false" , "\n"; echo "trait? ", $h->isTrait() ? "true" : "false" , "\n"; echo "interface? ", $h->isInterface() ? "true" : "false" , "\n"; echo "実体化可能? ", $h->isInstantiable() ? "true" : "false" , "\n"; } check("MyClass"); check("MyTrait"); check("MyInterface"); check("MyAbstract");
based on OfaSU
Output for 7.0.0
Parse error: syntax error, unexpected 'MyAbstract' (T_STRING), expecting abstract (T_ABSTRACT) or final (T_FINAL) or class (T_CLASS) in /in/41oC7 on line 23
Process exited with code 255.
Output for 5.4.10 - 5.6.16
Parse error: syntax error, unexpected 'MyAbstract' (T_STRING), expecting class (T_CLASS) in /in/41oC7 on line 23
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/41oC7 on line 12
Process exited with code 255.