3v4l.org

run code in 300+ PHP versions simultaneously
<?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));
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.7
Warning: 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.5 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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.3.32 - 7.3.33
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.0 - 5.6.38
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.0 - 5.5.38
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.0 - 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.

preferences:
248.82 ms | 401 KiB | 340 Q