PHP | ReflectionClass getConstants() Function Last Updated : 30 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ReflectionClass::getConstants() function is an inbuilt function in PHP which is used to return an array of the specified constant names. Syntax: array ReflectionClass::getConstants( void ) Parameters: This function does not accept any parameter. Return Value: This function returns an array of the specified constant names. Below programs illustrate the ReflectionClass::getConstants() function in PHP: Program 1: php <?php // Declaring a class named as Company class Company { // Defining some constants const First = "GeeksforGeeks"; const Second = "GFG"; } // Using the ReflectionClass() function // over the Company class $A = new ReflectionClass('Company'); // Calling the getConstants() function $a = $A->getConstants(); // Getting an array of the constants print_r($a); ?> Output: Array ( [First] => GeeksforGeeks [Second] => GFG ) Program 2: php <?php // Declaring a class named as Departments class Departments { // Defining some constants const First = "CSE"; const Second = "ECE"; const Third = "EE"; const Fourth = "Mechanical"; } // Using the ReflectionClass() function // over the Departments class $A = new ReflectionClass('Departments'); // Calling the getConstants() function $a = $A->getConstants(); // Getting an array of the constants print_r($a); ?> Output: Array ( [First] => CSE [Second] => ECE [Third] => EE [Fourth] => Mechanical ) Reference: https://www.php.net/manual/en/reflectionclass.getconstants.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getConstants() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads PHP | ReflectionClass getConstant() Function The ReflectionClass::getConstant() function is an inbuilt function in PHP which is used to return the value of the defined constant. Syntax: mixed ReflectionClass::getConstant( string $name ) Parameters: This function accepts a parameter Name which is the name of the defined constant. Return Value: 1 min read PHP | ReflectionClass hasConstant() Function The ReflectionClass::hasConstant() function is an inbuilt function in PHP which is used to check the specified constant is present or not. Syntax: bool ReflectionClass::hasConstant( string $name ) Parameters: This function accepts a single parameter $name which holds the name of the defined constant 1 min read PHP | ReflectionClass getConstructor() Function The ReflectionClass::getConstructor() function is an inbuilt function in PHP which is used to return the constructor of the specified class or NULL if the class is not having any constructor. Syntax: ReflectionMethod ReflectionClass::getConstructor( void ) Parameters: This function does not accept a 1 min read PHP | ReflectionClass getReflectionConstants() Function The ReflectionClass::getReflectionConstants() function is an inbuilt function in PHP which is used to return an array of ReflectionClassConstant objects. Syntax: array ReflectionClass::getReflectionConstants( void ) Parameters: This function does not accept any parameters. Return Value: This functio 2 min read PHP | ReflectionClass getReflectionConstant() Function The ReflectionClass::getReflectionConstant() function is an inbuilt function in PHP which is used to return the ReflectionClassConstant of the specified class's property. Syntax: ReflectionClassConstant ReflectionClass::getReflectionConstant( string $name ) Parameters: This function accepts a single 2 min read PHP | ReflectionClass getStartLine() Function The ReflectionClass::getStartLine() function is an inbuilt function in PHP which is used to return the line number from where the user defined class get started. Syntax: int ReflectionClass::getStartLine( void ) Parameters: This function does not accept any parameters. Return Value: This function re 1 min read PHP | ReflectionClass getTraitNames() Function The ReflectionClass::getTraitNames() function is an inbuilt function in PHP which is used to return an array of name of traits used by the user-defined class. Syntax: array ReflectionClass::getTraitNames( void ) Parameters: This function does not accept any parameters. Return Value: This function re 1 min read PHP | ReflectionClass getInterfaces() Function The ReflectionClass::getInterfaces() function is an inbuilt function in PHP which is used to return an associative array of interfaces. These returned array is containing keys as interface names and the array values as ReflectionClass objects. Syntax: array ReflectionClass::getInterfaces( void ) Par 2 min read PHP | ReflectionClass getDocComment() Function The ReflectionClass::getDocComment() function is an inbuilt function in PHP which is used to return the specified doc comments if it exists, otherwise returns false. Syntax: string ReflectionClass::getDocComment( void ) Parameters: This function does not accept any parameters.Return Value: This func 1 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 Like