The ReflectionFunction::invokeArgs() function is an inbuilt function in PHP which is used to return the result of the invoked function call.
Syntax:
mixed ReflectionFunction::invokeArgs( array $args )
Parameters: This function accepts a single parameter $args which holds the array of arguments passed to the called function.
Return Value: This function returns the result of the invoked function call.
Below programs illustrate the ReflectionFunction::invokeArgs() function in PHP:
Program 1:
<?php // Initializing a user-defined function function Company($Company_Name, $Role) { return sprintf("%s %s\r\n", $Company_Name, $Role); } // Using ReflectionFunction() over the specified // function company $function = new ReflectionFunction('company'); // Calling the invokeArgs() function $A = $function->invokeArgs(array('GeeksforGeeks', 'is a Computer Science Portal.')); // Getting the result of the invoked // function company echo $A; ?> |
GeeksforGeeks is a Computer Science Portal.
Program_2:
<?php // Initializing some user-defined functions function Trial1($First_Args, $Second_Args) { return sprintf("%s %s\r\n", $First_Args, $Second_Args); } function Trial2($First_Args, $Second_Args) { return sprintf("%s %s\r\n", $First_Args, $Second_Args); } // Using ReflectionFunction() over the above // specified functions $function = new ReflectionFunction('Trial1'); $function = new ReflectionFunction('Trial2'); // Calling the invokeArgs() function and the // result of the invoked function company echo $function->invokeArgs(array('a+a', '= 2a')); echo $function->invokeArgs(array('a*a', '= a^2')); ?> |
Output:
a+a = 2a a*a = a^2
Reference: https://www.php.net/manual/en/reflectionfunction.invokeargs.php
Recommended Posts:
- PHP | ReflectionMethod invokeArgs() Function
- PHP | ReflectionFunction invoke() Function
- PHP | ReflectionFunction export() Function
- PHP | ReflectionFunction __toString() Function
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

