标签:style blog color io ar div cti log sp
返回传递给函数的参数个数
<?php header("Content-Type: text/html; charset=UTF-8"); function foo() { $numargs = func_num_args(); echo "参数个数为: $numargs\n"; } foo(1, 2, 3); ?>
返回一个包含函数参数列表的数组
<?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); ?>
返回参数列表的某一项
<?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); ?>
func_num_args, func_get_arg, func_get-args 的区别与用法
标签:style blog color io ar div cti log sp
原文地址:http://www.cnblogs.com/shaoyikai/p/3951783.html