PHP | ReflectionFunction invokeArgs() Function
Last Updated :
19 Dec, 2019
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
function Company( $Company_Name , $Role ) {
return sprintf( "%s %s\r\n" , $Company_Name , $Role );
}
$function = new ReflectionFunction( 'company' );
$A = $function ->invokeArgs( array ( 'GeeksforGeeks' ,
'is a Computer Science Portal.' ));
echo $A ;
?>
|
Output:
GeeksforGeeks is a Computer Science Portal.
Program_2:
<?php
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 );
}
$function = new ReflectionFunction( 'Trial1' );
$function = new ReflectionFunction( 'Trial2' );
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...