PHP | ReflectionClass hasMethod() Function Last Updated : 12 Dec, 2021 Comments Improve Suggest changes Like Article Like Report The ReflectionClass::hasMethod() function is an inbuilt function in PHP which is used to check the specified method is present or not.Syntax: bool ReflectionClass::hasMethod( string $name ) Parameters: This function accepts a single parameter $name which holds the name of the method which are being checked.Return Value: This function returns TRUE if the specified method is present, otherwise returns FALSE.Below programs illustrate the ReflectionClass::hasMethod() function in PHP:Program 1: php <?php // Initialising a user-defined Class Departments class Departments { public function CSE() { } final protected function ECE() { } private static function EE() { } static function IT() { } private function Mechanical() { } } // Using ReflectionClass() over the // user-defined class Departments $class = new ReflectionClass('Departments'); // Calling the hasMethod() function $methods = $class->hasMethod('CSE'); // Getting the value true or false var_dump($methods); ?> Output: bool(true) Program 2: php <?php // Initialising a user-defined Class Company class Company { public function GeeksforGeeks() { } static function gfg() { } } // Using ReflectionClass() over the // user-defined class Company $class = new ReflectionClass('Company'); // Calling the hasMethod() function $methods = $class->hasMethod('TCS'); // Getting the value true or false var_dump($methods); ?> Output: bool(false) Reference: https://php.net/manual/en/reflectionclass.hasmethod.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass hasMethod() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads PHP | ReflectionClass getMethod() Function The ReflectionClass::getMethod() function is an inbuilt function in PHP which is used to return a ReflectionMethod for the specified class method. Syntax: ReflectionMethod ReflectionClass::getMethod ( string $name ) Parameters: This function accepts a parameter $name which is the method name. Return 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 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 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 PHP | ReflectionClass getEndLine() Function The ReflectionClass::getEndLine() function is an inbuilt function in PHP which is used to return the line number where the user defined class get ends. Syntax: int ReflectionClass::getEndLine( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the li 1 min read Like