标签:
<?php
class MyClass
{
}
class NotMyClass
{
}
$a = new MyClass;
$b = new NotMyClass;
var_dump($a instanceof MyClass);
var_dump($a instanceof NotMyClass);
//两种不同写法
function myhs(MyClass $obj)
{
echo "myhs在执行了!";
}
myhs($a);
myhs($b);
?>
instanceof 变量是否属于某一类 class 的实例
标签:
原文地址:http://www.cnblogs.com/jiufen/p/4988971.html