ReflectionClass::getProperties
获取属性
&reftitle.description;
public arrayReflectionClass::getProperties
intnullfilter&null;
获取反射过的属性。
&reftitle.parameters;
filter
可选的过滤器,过滤为所需类型的属性。它使用 ReflectionProperty 常量 来配置,默认获取所有类型的属性。
&reftitle.returnvalues;
ReflectionProperty 对象的数组。
&reftitle.changelog;
&Version;
&Description;
7.2.0
filter 现在允许为 null。
&reftitle.examples;
ReflectionClass::getProperties 过滤示例
这个示例延时了可选 filter 参数的用法,示例里实际上忽略了私有属性。
getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
foreach ($props as $prop) {
print $prop->getName() . "\n";
}
var_dump($props);
?>
]]>
&example.outputs.similar;
object(ReflectionProperty)#3 (2) {
["name"]=>
string(3) "foo"
["class"]=>
string(3) "Foo"
}
[1]=>
object(ReflectionProperty)#4 (2) {
["name"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
}
}
]]>
&reftitle.seealso;
ReflectionClass::getProperty
ReflectionProperty
ReflectionProperty 修饰符常量