主页
PHP
PHP instanceof 关键字
tryphp_keyword_instanceof
运行 ❯
×
更改方向
保存代码
更改主题
<?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
"; } ?>