PHP | ReflectionMethod invoke() Function Last Updated : 19 Jul, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The ReflectionMethod::invoke() function is an inbuilt function in PHP which is used to invoke the specified reflected method and returns the result of the method.Syntax: public mixed ReflectionMethod::invoke ( $object, $parameter ) Parameters: This function accepts two parameters which are illustrated below: object: This is the initialized class object.parameter: This is the zero or more parameters to be passed to the method. Return Value: This function returns the result of the invoked method.Below programs illustrate the ReflectionMethod::invoke() function in PHP: Program_1: php <?php // Initializing a user-defined class class Company { public function GFG($name) { return 'GeeksforGeeks' . $name; } } // Using ReflectionMethod() over the class Company $A = new ReflectionMethod('Company', 'GFG'); // Calling the invoke() function $B = $A->invoke(new Company(), ' is a Computer Science Portal.'); // Getting the result of the invoked method. echo $B; ?> Output: GeeksforGeeks is a Computer Science Portal. Program_2: php <?php // Initializing some user-defined classes class Department1 { public function hr($name) { return 'HR' . $name; } } class Department2 { public function coding($name) { return 'Coding' . $name; } } class Department3 { public function marketing($name) { return 'Marketing' . $name; } } // Using ReflectionMethod() over the above classes $A = new ReflectionMethod('Department1', 'hR'); $B = new ReflectionMethod('Department2', 'coding'); $C = new ReflectionMethod('Department3', 'marketing'); // Calling the invoke() function and // getting the result of the invoked method. echo $A->invoke(new Department1(), ' is a Department.'); echo "\n"; echo $B->invoke(new Department2(), ' is also a Department.'); echo "\n"; echo $C->invoke(new Department3(), ' too.'); ?> Output: HR is a Department. Coding is also a Department. Marketing too. Reference: https://www.php.net/manual/en/reflectionmethod.invoke.php, Comment More infoAdvertise with us Next Article PHP | ReflectionFunction invoke() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Similar Reads PHP | ReflectionMethod invokeArgs() Function The ReflectionMethod::invokeArgs() function is an inbuilt function in PHP which is used to invoke the specified reflected method and returns the result of the method.Syntax: mixed ReflectionMethod::invokeArgs ( $object, $parameter ) Parameters: This function accepts two parameters as mentioned above 2 min read PHP | ReflectionMethod isFinal() Function The ReflectionMethod::isFinal() function is an inbuilt function in PHP which is used to return TRUE if the specified method is final, otherwise returns FALSE. Syntax: bool ReflectionMethod::isFinal( void ) Parameters: This function does not accept any parameters. Return Value: This function returns 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 | ReflectionFunction invoke() Function The ReflectionFunction::invoke() function is an inbuilt function in PHP which is used to return the result of the invoked function call. Syntax: mixed ReflectionFunction::invoke( mixed $args) Parameters: This function accept parameter $args which holds the list of arguments passed to the called func 2 min read 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 Like