📜  PHP | ReflectionClass 实现Interface()函数

📅  最后修改于: 2022-05-13 01:56:35.113000             🧑  作者: Mango

PHP | ReflectionClass 实现Interface()函数

ReflectionClass::implementsInterface()函数是PHP中的一个内置函数,用于检查指定的接口是否存在。

句法:

bool ReflectionClass::implementsInterface( string $interface )

参数:此函数接受单个参数$interface ,其中包含正在检查的指定接口。

返回值:此函数在成功时返回 true,在失败时返回 false。

下面的程序说明了PHP中的 ReflectionClass::implementsInterface()函数:

方案一:

implementsInterface('Colleges');
  
// Getting the value true or false
var_dump($B);
?>
输出:
bool(true)

方案二:

implementsInterface('Company1');
  
// Getting the value either true or false
var_dump($A);
  
?>
输出:
bool(false)

参考: https://www. PHP.net/manual/en/reflectionclass.implementsinterface。 PHP