function hello() { echo "Hello World"; } $reflection = new ReflectionFunction('hello'); echo $reflection->getNumberOfParameters(); // Output: 0
function greet($name) { return "Hello " . $name; } $reflection = new ReflectionFunction('greet'); echo $reflection->getNumberOfParameters(); // Output: 1In the above example, the ReflectionFunction is used to inspect the "greet" function and return the number of parameters it expects. The output shows that the function expects one parameter. Package/Library: PHP Standard Library.