PHP | ReflectionClass getDefaultProperties() Function Last Updated : 30 Nov, 2019 Comments Improve Suggest changes Like Article Like Report 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. Return Value: This function returns an array of default properties. These properties are having space for property's keys and its values. The key is the name of the property and values are the default value of the property. And it also returns NULL if the property is not having any default values. Below programs illustrate the ReflectionClass::getDefaultProperties() function in PHP: Program 1: php <?php // Defining a class named as College class College { // Defining a protected property protected $College_Name = 'IIT Delhi'; } // Defining a sub class Departments of the // base class College class Departments extends College { public $Dept1 = 'CSE'; private $Dept2 = 'ECE'; public static $Dept3 = 'EE'; } // Using ReflectionClass over sub class Departments $ReflectionClass = new ReflectionClass('Departments'); // Getting an array of the default properties var_dump($ReflectionClass->getDefaultProperties()); ?> Output: array(4) { ["Dept3"]=> string(2) "EE" ["Dept1"]=> string(3) "CSE" ["Dept2"]=> string(3) "ECE" ["College_Name"]=> string(9) "IIT Delhi" } Program 2: php <?php // Defining a class named as College class College { // Defining a protected property protected $College_Name = 'IIT Delhi'; } // Defining a sub class Departments of the // base class College class Departments extends College { public $Dept1; private $Dept2; public static $Dept3; } // Using ReflectionClass over sub class Departments $ReflectionClass = new ReflectionClass('Departments'); // Getting an array of the default properties var_dump($ReflectionClass->getDefaultProperties()); ?> Output: array(4) { ["Dept3"]=> NULL ["Dept1"]=> NULL ["Dept2"]=> NULL ["College_Name"]=> string(9) "IIT Delhi" } Reference: https://www.php.net/manual/en/reflectionclass.getdefaultproperties.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getDefaultProperties() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads PHP | ReflectionClass getProperties() Function 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 propertie 2 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 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 getStaticPropertyValue() Function The ReflectionClass::getStaticPropertyValue() function is an inbuilt function in PHP which is used to return the value of the static property. Syntax: mixed ReflectionClass::getStaticPropertyValue( string $name, mixed &$def_value ) Parameters: This function accepts a single parameter name which is t 1 min read PHP | ReflectionClass getTraitAliases() Function The ReflectionClass::getTraitAliases() function is an inbuilt function in PHP which is used to return an array of trait aliases used by the user-defined class.Syntax: array ReflectionClass::getTraitAliases( void ) Parameters: This function does not accept any parameters.Return Value: This function r 1 min read Like