3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface I { } class A implements I { } class B extends A { } $b = new B(); echo "B <-> I:\n"; var_dump($b instanceof I); var_dump(is_a($b, "I")); var_dump(is_subclass_of($b, "I")); $rc = new ReflectionClass("B"); var_dump($rc->getInterfaceNames()); echo "\n\nB <-> A:\n"; var_dump($b instanceof A); var_dump(is_a($b, "A")); var_dump(is_subclass_of($b, "A"));
Output for 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.29, 7.4.0 - 7.4.22, 8.0.0 - 8.0.8
B <-> I: bool(true) bool(true) bool(true) array(1) { [0]=> string(1) "I" } B <-> A: bool(true) bool(true) bool(true)

preferences:
537.99 ms | 460 KiB | 5 Q