开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜