(PHP 5, PHP 7, PHP 8)
ReflectionClass::getProperty — Gets a ReflectionProperty for a class's property
public ReflectionClass::getProperty(string $name): ReflectionProperty
Gets a ReflectionProperty for a class's property.
nameThe property name.
Example #1 Basic usage of ReflectionClass::getProperty()
<?php
$class = new ReflectionClass('ReflectionClass');
$property = $class->getProperty('name');
var_dump($property);
?> The above example will output:
object(ReflectionProperty)#2 (2) {
["name"]=>
string(4) "name"
["class"]=>
string(15) "ReflectionClass"
}
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectionclass.getproperty.php