func_num_args
返回传递给函数的参数个数
<?php header("Content-Type: text/html; charset=UTF-8"); function foo() { $numargs = func_num_args(); echo "参数个数为: $numargs "; } foo(1, 2, 3); ?>
func_get_args
返回一个包含函数参数列表的数组
<?php header("Content-Type: text/html; charset=UTF-8"); function foo() { $numargs = func_num_args(); echo "参数个数为: $numargs<br /> "; if ($numargs >= 2) { echo "第2个参数是:" . func_get_arg(1) . "<br /> "; } $arg_list = func_get_args(); var_dump($arg_list); } foo(1, 2, 3); ?>
func_get_arg
返回参数列表的某一项
<?php header("Content-Type: text/html; charset=UTF-8"); function foo() { $numargs = func_num_args(); echo "参数个数是: $numargs<br /> "; if ($numargs >= 2) { echo "第2个参数是:" . func_get_arg(1) . "<br /> "; } } foo (1, 2, 3); ?>