function add($a, $b) { return $a + $b; } $reflectionFunc = new ReflectionFunction('add'); $args = array(2, 3); $result = $reflectionFunc->invokeArgs($args); echo $result; // Output: 5
function echoString($str) { echo $str; } $reflectionFunc = new ReflectionFunction('echoString'); $args = array("Hello, world!"); $reflectionFunc->invokeArgs($args);This example invokes the `echoString` function with argument `$str = "Hello, world!"`, using the ReflectionFunction `invokeArgs` method, which echoes the string "Hello, world!". Package library: The ReflectionFunction class is a part of the PHP Core library and does not require any external package/library.