运行 ❯
获取你
自己的 PHP
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <?php class MyClass {} class AnotherClass extends MyClass{} $obj = new AnotherClass(); if($obj instanceof AnotherClass) { echo "The object is AnotherClass"; } // The object is also an instance of the class it is derived from if($obj instanceof MyClass) { echo "The object is MyClass<br>"; } ?> </body> </html>
对象为 AnotherClass 对象为 MyClass