3v4l.org

run code in 300+ PHP versions simultaneously
<?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 class 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 "instantiable? ", $h->isInstantiable() ? "true" : "false" , "\n"; } check("MyClass"); check("MyTrait"); check("MyInterface"); check("MyAbstract");
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
================ MyClass ================= abstract? false trait? false interface? false instantiable? true ================ MyTrait ================= abstract? false trait? true interface? false instantiable? false ================ MyInterface ================= abstract? true trait? false interface? true instantiable? false ================ MyAbstract ================= abstract? true trait? false interface? false instantiable? false
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
================ MyClass ================= abstract? false trait? false interface? false instantiable? true ================ MyTrait ================= abstract? true trait? true interface? false instantiable? false ================ MyInterface ================= abstract? true trait? false interface? true instantiable? false ================ MyAbstract ================= abstract? true trait? false interface? false instantiable? false

preferences:
232.11 ms | 403 KiB | 330 Q