PHP | ReflectionClass getReflectionConstant() Function Last Updated : 30 Nov, 2019 Comments Improve Suggest changes Like Article Like Report 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 parameter name which is the name of the class constant. Return Value: This function returns the ReflectionClassConstant of the specified class's property. Below programs illustrate the ReflectionClass::getReflectionConstant() 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 getReflectionConstant() function // over the constant 'First' $a = $A->getReflectionConstant('First'); // Getting the ReflectionClassConstant print_r($a); ?> Output: ReflectionClassConstant Object ( [name] => First [class] => Company ) Program 2: php <?php // Declaring a user-defined class Departments class Departments { // Defining some constants const D1 = "EE"; const D2 = "Civil"; const D3 = "CSE"; const D4 = "IT"; } // Using the ReflectionClass() function // over the Departments class $A = new ReflectionClass('Departments'); // Calling the getReflectionConstant() function // over specified constants $a1 = $A->getReflectionConstant('D1'); $a2 = $A->getReflectionConstant('D2'); $a3 = $A->getReflectionConstant('D3'); $a4 = $A->getReflectionConstant('D4'); // Getting the ReflectionClassConstant print_r($a1); print_r($a2); print_r($a3); print_r($a4); ?> Output: ReflectionClassConstant Object ( [name] => D1 [class] => Departments ) ReflectionClassConstant Object ( [name] => D2 [class] => Departments ) ReflectionClassConstant Object ( [name] => D3 [class] => Departments ) ReflectionClassConstant Object ( [name] => D4 [class] => Departments ) Reference: https://www.php.net/manual/en/reflectionclass.getreflectionconstant.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getReflectionConstants() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads 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 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 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 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 getConstants() Function 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 th 2 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 Like