check params required in php
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 retur开发者_如何学JAVAn 1// as $bar is optional :)
    $reflection = new ReflectionFunction($function_name);
    $reflection->getNumberOfParameters();
    $reflection->getNumberOfRequiredParameters();
Try function reflections: http://lv.php.net/manual/en/class.reflectionfunction.php
You'd have to use the Reflection functions in PHP, such as ReflectionFunction, especially ReflectionFunction::getParameters
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论