PHP | ReflectionMethod getPrototype() Function Last Updated : 23 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The ReflectionMethod::getPrototype() function is an inbuilt function in PHP which is used to return the prototype of the specified method otherwise, an exception/error is returned if the method does not have a prototype. Syntax: ReflectionMethod ReflectionMethod::getPrototype( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the prototype of the specified method otherwise, an exception/error is returned if the method does not have a prototype. Below programs illustrate the ReflectionMethod::getPrototype() function in PHP: Program 1: php <?php // Initializing a user-defined class Department1 class Department1 { public function Marketing_Dpt() { return 'Department1'; } } // Initializing a subclass of the above class Department1 class Department2 extends Department1{ public function Marketing_Dpt() { return 'Department2'; } } // Again Initializing a subclass of the above subclass Department2 class Department3 extends Department2{ public function Coding_Dpt() { return 'Department3'; } } // Using the ReflectionMethod() over the above // subclass Department2 $A = new ReflectionMethod('Department3', 'Marketing_Dpt'); // Calling the getPrototype() function $B = $A->getPrototype(); // Getting the prototype var_dump($B); ?> Output: object(ReflectionMethod)#2 (2) { ["name"]=> string(13) "Marketing_Dpt" ["class"]=> string(11) "Department1" } Program 2: php <?php // Initializing a user-defined class class Company { protected function GeeksforGeeks($name) { return 'GFG' . $name; } } // Using ReflectionMethod() over the class Company $A = new ReflectionMethod('Company', 'GeeksforGeeks'); // Calling the getPrototype() function $B = $A->getPrototype(); // Getting the prototype or an error is returned // if the method does not have a prototype. var_dump($B); ?> Output: Method does not have any prototype that will give you an error. PHP Fatal error: Uncaught ReflectionException: Method Company:: GeeksforGeeks does not have a prototype in /home/9d8367b263ee4d7ec6941876b0eae792.php:15 Stack trace: #0 /home/9d8367b263ee4d7ec6941876b0eae792.php(15): ReflectionMethod->getPrototype() #1 {main} thrown in /home/9d8367b263ee4d7ec6941876b0eae792.php on line 15 Reference: https://www.php.net/manual/en/reflectionmethod.getprototype.php Comment More infoAdvertise with us Next Article PHP | ReflectionParameter getType() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Similar Reads PHP | ReflectionMethod isProtected() Function The ReflectionMethod::isProtected() function is an inbuilt function in PHP which is used to return TRUE if the specified method is protected, otherwise returns FALSE. Syntax: bool ReflectionMethod::isProtected ( void ) Parameters: This function does not accept any parameters. Return Value: This func 2 min read PHP | ReflectionMethod getClosure() Function The ReflectionMethod::getClosure() function is an inbuilt function in PHP which is used to return a dynamically created closure for the method otherwise, return NULL in case of an error. Syntax: Closure ReflectionMethod::getClosure ( $object ) Parameters: This function accepts a parameter object whi 2 min read PHP | ReflectionMethod isPrivate() Function The ReflectionMethod::isPrivate() function is an inbuilt function in PHP which is used to return TRUE if the specified method is private, otherwise returns FALSE. Syntax: bool ReflectionMethod::isPrivate( void ) Parameters: This function does not accept any parameters. Return Value: This function re 2 min read PHP | ReflectionParameter getType() Function The ReflectionParameter::getType() function is an inbuilt function in PHP which is used to return the type of the specified parameter. Syntax: ReflectionType ReflectionParameter::getType ( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the type o 2 min read PHP | ReflectionMethod getModifiers() Function The ReflectionMethod::getModifiers() function is an inbuilt function in PHP which is used to return the numeric representation of the method modifiers. Syntax: int ReflectionMethod::getModifiers( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the 1 min read PHP | ReflectionMethod isDestructor() Function The ReflectionMethod::isDestructor() function is an inbuilt function in PHP which is used to return TRUE if the specified method is destructor, otherwise FALSE. Syntax: bool ReflectionMethod::isDestructor( void ) Parameters: This function does not accept any parameters. Return Value: This function r 1 min read Like