标签:empty foreach 数组 pass 方式 div world index 索引
1, 用到的PHP函数: func_get_arg() / func_get_args()/ func_num_args
function foo() { $numargs = func_num_args(); echo "Number of arguments: $numargs<br />\n"; if ($numargs >= 2) { echo "Second argument is: " . func_get_arg(1) . "<br />\n"; } } foo (1, 2, 3); ?>
function foo() { // returns an array of all passed arguments $args = func_get_args(); foreach ($args as $k => $v) { echo “arg”.($k+1).”: $v\n”; } } foo(); /* 没用任何输出*/ foo(‘hello’); /* 输出 arg1: hello */ foo(‘hello’, ‘world’, ‘again’); /*输出 arg1: hello arg2: world arg3: again */
function foo() { $numargs = func_num_args(); echo “Number of arguments: $numargs\n“; } foo(1, 2, 3); // Prints ‘Number of arguments: 3′ ?>
function foo() { $numargs = func_num_args();//得到参数的个数 echo "Number of arguments: $numargs<br />\n"; if ($numargs >= 2) { echo "Second argument is: " . func_get_arg(1) . "<br />\n"; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "Argument $i is: " . $arg_list[$i] . "<br />\n"; } } foo(1, 2, 3); ?>
标签:empty foreach 数组 pass 方式 div world index 索引
原文地址:http://www.cnblogs.com/qianlizeguo/p/6834570.html