php关键字:instanceof
判断一个对象是否是某一个类的实例
<?php
abstract class Test
{
abstract function func1();
}
interface TestInterface
{
public function func2();
}
class a extends Test implements TestInterface
{
public function func1()
{
echo __METHOD__;
}
public function func2()
{
echo __METHOD__;
}
}
$cls = new a;
var_dump($cls instanceof Test); // true
var_dump($cls instanceof TestInterface); // true
var_dump($cls instanceof a); // true
?>