func_num_args
返回传递给函数的参数个数
<?php header("Content-Type: text/html; charset=UTF-8"); function foo() { $numargs = func_num_args(); echo "参数个数为: $numargs\n"; } 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 />\n"; if ($numargs >= 2) { echo "第2个参数是:" . func_get_arg(1) . "<br />\n"; } $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 />\n"; if ($numargs >= 2) { echo "第2个参数是:" . func_get_arg(1) . "<br />\n"; } } foo (1, 2, 3); ?>
时间: 2024-11-01 23:54:42