REFLECTIONMETHOD.INVOKEARGS(3) 1 REFLECTIONMETHOD.INVOKEARGS(3)
ReflectionMethod::invokeArgs - Invoke args
SYNOPSIS
public mixed ReflectionMethod::invokeArgs (object $object, array $args)
DESCRIPTION
Invokes the reflected method and pass its arguments as array.
PARAMETERS
o $object
- The object to invoke the method on. In case of static methods, you can pass null to this parameter.
o $args
- The parameters to be passed to the function, as an array.
RETURN VALUES
Returns the method result.
ERRORS
/EXCEPTIONS
A ReflectionException if the $object parameter does not contain an instance of the class that this method was declared in.
A ReflectionException if the method invocation failed.
EXAMPLES
Example #1
ReflectionMethod::invokeArgs example
<?php
class HelloWorld {
public function sayHelloTo($name) {
return 'Hello ' . $name;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
echo $reflectionMethod->invokeArgs(new HelloWorld(), array('Mike'));
?>
The above example will output:
Hello Mike
NOTES
Note
If the function has arguments that need to be references, then they must be references in the passed argument list.
SEE ALSO
ReflectionMethod::invoke, __invoke(), call_user_func_array(3).
PHP Documentation Group REFLECTIONMETHOD.INVOKEARGS(3)