3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo {}; class Bar extends Foo {}; $reflection_foo = new ReflectionClass(Foo::class); $testClass = function($class) use ($reflection_foo) { $reflection = new ReflectionClass($class); return $reflection->isSubclassOf(Foo::class) || ($reflection->getName() == $reflection_Foo->getName()); }; var_dump($testClass(Foo::class), $testClass(Bar::class));
based on BSunj
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: reflection_Foo in /in/6sqlv on line 10 Fatal error: Uncaught Error: Call to a member function getName() on null in /in/6sqlv:10 Stack trace: #0 /in/6sqlv(13): {closure}('Foo') #1 {main} thrown in /in/6sqlv on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: reflection_Foo in /in/6sqlv on line 10 Fatal error: Uncaught Error: Call to a member function getName() on unknown in /in/6sqlv:10 Stack trace: #0 /in/6sqlv(13): {closure}('Foo') #1 {main} thrown in /in/6sqlv on line 10
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Notice: Undefined variable: reflection_Foo in /in/6sqlv on line 10 Fatal error: Call to a member function getName() on null in /in/6sqlv on line 10
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Notice: Undefined variable: reflection_Foo in /in/6sqlv on line 10 Fatal error: Call to a member function getName() on a non-object in /in/6sqlv on line 10
Process exited with code 255.
Output for 5.4.2 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/6sqlv on line 6
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /in/6sqlv on line 6
Process exited with code 255.