PHP | ReflectionClass getProperties() Function Last Updated : 30 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ReflectionClass::getProperties() function is an inbuilt function in PHP which is used to return an array of the reflected properties. Syntax: ReflectionClass::getProperties($filter) : array Parameters: This function accepts a parameter filter which helps to remove some of the reflected properties. Return Value: This function returns an array of the reflected properties. Below programs illustrate the ReflectionClass::getProperties() function in PHP: Program 1: php <?php // Defining a class named as Departments class Departments { public $Dept1 = 'CSE'; private $Dept2 = 'ECE'; public static $Dept3 = 'EE'; } // Using ReflectionClass over the class Departments $ReflectionClass = new ReflectionClass('Departments'); // Calling getProperties() function over a filter called // ReflectionProperty::IS_PUBLIC which // will reflect results of only public properties $A = $ReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC); // Getting an array of the reflected properties var_dump($A); ?> Output: array(2) { [0]=> object(ReflectionProperty)#2 (2) { ["name"]=> string(5) "Dept1" ["class"]=> string(11) "Departments" } [1]=> object(ReflectionProperty)#3 (2) { ["name"]=> string(5) "Dept3" ["class"]=> string(11) "Departments" } } Program 2: php <?php // Defining a class named as Company class Company { public $C1; private $C2; public static $C3; } // Using ReflectionClass over the class Company $ReflectionClass = new ReflectionClass('Company'); // Calling getProperties() function without // of any filter $A = $ReflectionClass->getProperties(); // Getting an array of the reflected properties var_dump($A); ?> Output: array(3) { [0]=> object(ReflectionProperty)#2 (2) { ["name"]=> string(2) "C1" ["class"]=> string(7) "Company" } [1]=> object(ReflectionProperty)#3 (2) { ["name"]=> string(2) "C2" ["class"]=> string(7) "Company" } [2]=> object(ReflectionProperty)#4 (2) { ["name"]=> string(2) "C3" ["class"]=> string(7) "Company" } } Reference: https://www.php.net/manual/en/reflectionclass.getproperties.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getProperties() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads PHP | ReflectionClass getProperty() Function The ReflectionClass::getProperty() function is an inbuilt function in PHP which is used to return an array of the ReflectionProperty for the specified class. Syntax: ReflectionClass::getProperty ( string $name ) : array Parameters: This function accepts a parameter name which is name of the property 1 min read PHP | ReflectionClass getStaticProperties() Function The ReflectionClass::getStaticProperties() function is an inbuilt function in PHP which is used to return an array of the static properties. This function is not documented currently, but its argument list is available. Syntax: ReflectionClass::getStaticProperties(void) : array Parameters: This func 1 min read PHP | ReflectionClass getDefaultProperties() Function The ReflectionClass::getDefaultProperties() function is an inbuilt function in PHP which is used to return the default properties including inherited properties from a specified class. Syntax: ReflectionClass::getDefaultProperties(void) : array Parameters: This function does not accept any parameter 2 min read PHP | ReflectionClass getParentClass() Function The ReflectionClass::getParentClass() function is an inbuilt function in PHP which is used to return the specified parent class or false if there is no parent class is present. Syntax: ReflectionClass ReflectionClass::getParentClass ( void ) Parameters: This function does not accept any parameters. 2 min read PHP | ReflectionClass getExtension() Function The ReflectionClass::getExtension() function is an inbuilt function in PHP which is used to return the ReflectionExtension object which represents the extension for the defined class, or NULL for the user-defined classes. Syntax: ReflectionExtension ReflectionClass::getExtension( void ) Parameters: 1 min read Like