如何在运行时检查 PHP 中方法或函数的许多参数。
例子
class foo { function bar ( arg1, arg2 ){ ..... } }
我需要知道是否有办法运行类似的东西
get_func_arg_number ( "foo", "bar" )
结果是
2
最佳答案
您需要使用 reflection这样做。
$method = new ReflectionMethod('foo', 'bar');
$num = $method->getNumberOfParameters();
关于php - 如何在php中动态检查函数的参数数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/346777/