PHP ReflectionClass getMethods() Function Last Updated : 18 Aug, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: This function returns an array of specified methods.Below programs illustrate the ReflectionClass::getMethods() function in PHP:Program 1: php <?php // Initialising a user-defined Class 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 getMethods() function $methods = $class->getMethods(); // Getting an array of specified methods var_dump($methods); ?> Outputarray(5) { [0]=> object(ReflectionMethod)#2 (2) { ["name"]=> string(3) "CSE" ["class"]=> string(11) "Departments" } [1]=> object(ReflectionMethod)#3 (2) { ["name"]=> string(3) "ECE" ["class"]=> string(11) "Departments" } [2]=> object(ReflectionMethod)#4 (2) { ["name"]=> string(2) "EE" ["class"]=> string(11) "Departments" } [3]=> object(ReflectionMethod)#5 (2) { ["name"]=> string(2) "IT" ["class"]=> string(11) "Departments" } [4]=> object(ReflectionMethod)#6 (2) { ["name"]=> string(10) "Mechanical" ["class"]=> string(11) "Departments" } } Program 2: php <?php // Initialising a user-defined Class 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 getMethods() function $methods = $class->getMethods(ReflectionMethod::IS_STATIC); // Getting an array of specified methods var_dump($methods); ?> Outputarray(2) { [0]=> object(ReflectionMethod)#2 (2) { ["name"]=> string(2) "EE" ["class"]=> string(11) "Departments" } [1]=> object(ReflectionMethod)#3 (2) { ["name"]=> string(2) "IT" ["class"]=> string(11) "Departments" } } Reference: https://www.php.net/manual/en/reflectionclass.getmethods.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getMethod() 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 hasMethod() Function 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 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 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 PHP | ReflectionClass getFileName() Function The ReflectionClass::getFileName() function is an inbuilt function in PHP which is used to return the filename of the file in which the class has been defined or returns false if the file is not found. Syntax: string ReflectionClass::getFileName( void ) Parameters: This function does not accept any 1 min read PHP | ReflectionClass getProperty() Function The ReflectionClass::getProperty() function is an inbuilt function in PHP which is used to return an array of the ReflectionProperty for the specified class. Syntax: ReflectionClass::getProperty ( string $name ) : array Parameters: This function accepts a parameter name which is name of the property 1 min read Like