PHP | ReflectionClass getConstant() Function Last Updated : 30 Nov, 2019 Comments Improve Suggest changes Like Article Like Report 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: This function returns the value of the defined constant. Below programs illustrate the ReflectionClass::getConstant() function in PHP: Program 1: php <?php // Declaring a class named as Department class Department { // Defining a constant const First = "CSE"; } // Using the ReflectionClass() function // over the Department class $A = new ReflectionClass('Department'); // Calling the getConstant() function over // First constant $a = $A->getConstant('First'); // Getting the value of the defined constant print_r($a); ?> Output: CSE Program 2: php <?php // Declaring a class named as Company class Company { // Defining a constant const First = "GeeksforGeeks"; const Second = "GFG"; const Third = "gfg"; } // Using the ReflectionClass() function // over the Company class $A = new ReflectionClass('Company'); // Calling the getConstant() function over // the defined constants and // getting the value of the defined constants print_r($A->getConstant('First')); echo("\n"); print_r($A->getConstant('Second')); echo("\n"); print_r($A->getConstant('Third')); ?> Output: GeeksforGeeks GFG gfg Reference: https://www.php.net/manual/en/reflectionclass.getconstant.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getConstant() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads 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 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 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 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 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 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 PHP ReflectionClass getMethods() Function The ReflectionClass::getMethods() function is an inbuilt function in PHP which is used to return an array of specified methods.Syntax: array ReflectionClass::getMethods( int $filter )Parameters: This function accepts a single parameter filter which is used to remove some of the methods.Return Value: 2 min read PHP | ReflectionClass isInstance() Function The ReflectionClass::isInstance() function is an inbuilt function in PHP which is used to check whether the specified object is an instance of the class or not. Syntax: bool ReflectionClass::isInstance( object $object ) Parameters: This function accepts a single parameter object which is being searc 1 min read Like