(PHP 5, PHP 7)
ReflectionClass::isInstantiable — ������Ƿ��ʵ����
���������Ƿ��ʵ������
�˺���û�в�����
�ɹ�ʱ���� TRUE
�� ������ʧ��ʱ���� FALSE
��
Example #1 ReflectionClass::isInstantiable() ����
<?php
class C { }
interface iface {
function f1();
}
class ifaceImpl implements iface {
function f1() {}
}
abstract class abstractClass {
function f1() { }
abstract function f2();
}
class D extends abstractClass {
function f2() { }
}
class privateConstructor {
private function __construct() { }
}
$classes = array(
"C",
"iface",
"ifaceImpl",
"abstractClass",
"D",
"privateConstructor",
);
foreach($classes as $class ) {
$reflectionClass = new ReflectionClass($class);
echo "Is $class instantiable? ";
var_dump($reflectionClass->IsInstantiable());
}
?>
�������̻������
Is C instantiable? bool(true) Is iface instantiable? bool(false) Is ifaceImpl instantiable? bool(true) Is abstractClass instantiable? bool(false) Is D instantiable? bool(true) Is privateConstructor instantiable? bool(false)