(PHP 5)
ReflectionClass::isInstance — Checks class for instance
Checks if a class is an instance of an object.
The object being compared to.
如果成功则返回 TRUE,失败则返回 FALSE。
Example #1 ReflectionClass::isInstance related examples
<?php
// Example usage
$class = new ReflectionClass('Foo');
if ($class->isInstance($arg)) {
echo "Yes";
}
// Equivalent to
if ($arg instanceof Foo) {
echo "Yes";
}
// Equivalent to
if (is_a($arg, 'Foo')) {
echo "Yes";
}
?>
上例的输出类似于:
Yes Yes Yes