Reputation: 4615
Is there any method for finding the number of parameters a php function will accept, Like
pow - 2
strlen - 2
sqrt - 1
I have dome some research and got to ReflectionFunctionAbstract::getNumberOfParameters
. But it seems ReflectionMethod
needs a class
and a method
. Here i don't have a class object.
Also I cannot use func_num_args
method since for that I have to be inside the method, which is not possible.
Upvotes: 0
Views: 54
Reputation: 38502
Try it, this may meet your requirements...
$info = new ReflectionFunction('sqrt');
#print $info->getNumberOfRequiredParameters();
var_dump(
$info->getName(),
$info->getNumberOfParameters(),
$info->getNumberOfRequiredParameters()
);
Upvotes: 1