(PHP 5, PHP 7, PHP 8)
ReflectionClass::isInstance — 检查类的实例
object待比较的对象。
示例 #1 ReflectionClass::isInstance() 相关示例
<?php
class Foo {}
$object = new Foo();
$reflection = new ReflectionClass('Foo');
if ($reflection->isInstance($object)) {
echo "Yes\n";
}
// Equivalent to
if ($object instanceof Foo) {
echo "Yes\n";
}
// Equivalent to
if (is_a($object, 'Foo')) {
echo "Yes";
}
?>以上示例的输出类似于:
Yes Yes Yes