ReflectionClass::getProperty
(PHP 5, PHP 7, PHP 8)
ReflectionClass::getProperty — 获取类的一个属性的 ReflectionProperty
说明
获取类的一个属性的 ReflectionProperty。
参数
name-
属性名。
返回值
示例
示例 #1 ReflectionClass::getProperty() 的基本用法
<?php
$class = new ReflectionClass('ReflectionClass');
$property = $class->getProperty('name');
var_dump($property);
?>以上示例会输出:
object(ReflectionProperty)#2 (2) {
["name"]=>
string(4) "name"
["class"]=>
string(15) "ReflectionClass"
}