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 Create Quiz Comment K Kanchan_Ray Follow 0 Improve K Kanchan_Ray Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like