Reputation: 17522
is there a way to find out how many parameters/arguments does the function expect?
lets say
function foo($par,$bar=false){
...
}
//fictional function below
echo numbr_of_params('foo'); // should return 1// as $bar is optional :)
Upvotes: 0
Views: 175
Reputation: 546045
You'd have to use the Reflection functions in PHP, such as ReflectionFunction, especially ReflectionFunction::getParameters
Upvotes: 0
Reputation: 17762
Try function reflections: http://lv.php.net/manual/en/class.reflectionfunction.php
Upvotes: 0
Reputation: 16035
$reflection = new ReflectionFunction($function_name);
$reflection->getNumberOfParameters();
$reflection->getNumberOfRequiredParameters();
Upvotes: 1