instanceof 变量是否属于某一类 class 的实例
<?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);
?>