开发者

Get method's arguments?

I can check all available methods for an object like so:

$methods = get_class_methods($object);

But how can I see which argum开发者_运维问答ents have to be sent to these methods?

Is there a function for this?


You can use reflection...

$r = new ReflectionMethod($className, $methodName);
$params = $r->getParameters();
foreach ($params as $param) {
    //$param is an instance of ReflectionParameter
    echo $param->getName();
    echo $param->isOptional();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜