PHP | ReflectionClass hasConstant() Function Last Updated : 04 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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. Return Value: This function returns TRUE if the constant is define, FALSE otherwise. Below programs illustrate the ReflectionClass::hasConstant() function in PHP: Program 1: php <?php // Defining a user-defined class Company class Company { const c1 = 'GeeksforGeeks'; } // Using the ReflectionClass over the // defined user-defined class Company $constant = new ReflectionClass("Company"); // Calling the hasConstant() function $const = $constant->hasConstant("c1"); // Getting the value TRUE or FALSE var_dump($const); ?> Output: bool(true) Program 2: php <?php // Defining an empty class class Company { } // Using the ReflectionClass over the // defined user-defined class Company $constant = new ReflectionClass("Company"); // Calling the hasConstant() function and // getting the value TRUE or FALSE var_dump($constant->hasConstant("c1")); ?> Output: bool(false) Reference: https://secure.php.net/manual/en/reflectionclass.hasconstant.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass hasConstant() 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 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 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 PHP | ReflectionClass isInstantiable() Function The ReflectionClass::isInstantiable() function is an inbuilt function in PHP which is used to check the specified class is instantiable or not. Syntax: bool ReflectionClass::isInstantiable( void ) Parameters: This function does not accept any parameters. Return Value: This function returns TRUE if t 1 min read PHP | ReflectionClass isAbstract() Function The ReflectionClass::isAbstract() function is an inbuilt function in PHP which is used to check the specified class is abstract or not. Syntax: bool ReflectionClass::isAbstract( void ) Parameters: This function does not accept any parameters. Return Value: This function returns true for the success 1 min read Like