3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { function a() {echo "a";} } class B { function a() {echo "b";} } class C extends A { function a() {echo "c";} } $b = new B(); var_dump($b instanceof A); $c = new C(); var_dump($c instanceof A); var_dump('bla' instanceof A); var_dump(null instanceof A);
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.6
bool(false) bool(true) bool(false) bool(false)
Output for 7.3.16 - 7.3.31, 7.4.3 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /in/65ocv on line 2 bool(false) abool(true) bool(false) bool(false)
Output for 7.3.32 - 7.3.33
bool(false) abool(true) bool(false) bool(false)
Output for 7.2.29 - 7.2.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in /in/65ocv on line 2 Fatal error: instanceof expects an object instance, constant given in /in/65ocv on line 13
Process exited with code 255.
Output for 5.3.7 - 5.3.28, 5.4.0 - 5.4.26
Fatal error: instanceof expects an object instance, constant given in /in/65ocv on line 13
Process exited with code 255.

preferences:
124.36 ms | 402 KiB | 189 Q