我的问题很像这个问题:PHP:获取参数计数
除了我需要计算方法的参数(如果您愿意的话),但是这个方法在一个对象中。
我试过这个:
$reflection = new ReflectionFunction($_SITE,$acao);
$qtdArgumentos = $reflection->getNumberOfParameters();这是:
$reflection = new ReflectionFunction($_SITE->$acao);
$qtdArgumentos = $reflection->getNumberOfParameters();并得到了以下错误:
致命错误:带有消息‘函数ReflectionException’的未命名异常‘$_SITE,$acao()不存在’C:\wamp\www\project\index.php:20堆栈跟踪:#0 C:\wamp\www\project\index.php( 20 ):ReflectionFunction->_construct(‘$_SITE,$acao') #1 {main}抛入第20行的C:\wamp\www\projeto\index.php中。
是否有人知道另一种计算方法参数数量的方法是在对象内,还是在我的代码的变通方法中?
发布于 2012-12-12 19:57:16
我想你需要的是ReflectionMethod
$reflection = new ReflectionMethod($_SITE, $acao);
$qtdArgumentos = $reflection->getNumberOfParameters();https://stackoverflow.com/questions/13847509
复制相似问题