是否有一个 PHP 函数可以为我提供传递的参数 (func_get_args) 和任何未传递的默认值?
Note: This function returns a copy of the passed arguments only, and does not account for default (non-passed) arguments.
最佳答案
function test($a, $b = 10) {
echo $a, ' ', $b;
}
$rf = new ReflectionFunction('test');
foreach ($rf->getParameters() as $p) {
echo $p->getName(), ' - ', $p->isDefaultValueAvailable() ?
$p->getDefaultValue() : 'none', PHP_EOL;
}
关于php - 如何获取 func_get_args 和默认值以与 call_user_func_array 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36937399/