1、func_num_args() 返回传递给该函数参数的个数
[php] view plain copy
function foo()
{
$numargs = func_num_args();
echo $numargs; //输出3
}
foo(1, 2, 3);
?>
2、func_get_arg(int $arg_num) 取得指定位置的参数值,$arg_num位置index从0开始n-1。
[php] view plain copy
function foo()
{
$numargs = func_num_args();
echo $numargs; //输出3
if ($numargs >= 2) {
echo func_get_arg(1); //输出2
}
}
foo (1, 2, 3);
?>
3、func_get_args() 返回包含所有参数的数组
[php] view plain copy
function foo()
{
$numargs = func_get_args();
var_dump($numargs); //输出 array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
}
foo(1, 2, 3);
?>