📌  相关文章
📜  PHP | ReflectionParameter getClass()函数

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

PHP | ReflectionParameter getClass()函数

ReflectionParameter::getClass()函数是PHP中的一个内置函数,用于返回为参数提示的类类型。

句法:

ReflectionClass ReflectionParameter::getClass ( void )

参数:此函数不接受任何参数。

返回值:此函数返回为参数提示的类类型。

下面的程序说明了PHP中的ReflectionParameter::getClass()函数
方案一:

getClass();
  
// Getting the class type hinted for the parameter.
var_dump($B);
?>

输出:

object(ReflectionClass)#2 (1) {
  ["name"]=>
  string(9) "Exception"
}

方案二:

getClass());
var_dump($B->getClass());
var_dump($C->getClass());
?>

输出:

NULL
object(ReflectionClass)#4 (1) {
  ["name"]=>
  string(9) "Exception"
}
NULL

参考: https://www. PHP.net/manual/en/reflectionparameter.getclass。 PHP