(PHP 5, PHP 7, PHP 8)
ReflectionClass::getProperties — 獲取一組屬性
$filter = ?): array獲取反射過的屬性。
ReflectionProperty 對象的數(shù)組。
示例 #1 ReflectionClass::getProperties() 過濾例子
這個例子延時了可選 filter 參數(shù)的用法,例子里實際上忽略了私有屬性。
以上例程的輸出類似于:
foo
bar
array(2) {
[0]=>
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"
}
}