关于函数的参数列表动态个数问题,很急啊 function test(){ $args = func_get_args(); echo array_sum($args);}test(1,2,3,4);希望对你有所帮助。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼上的误解了,我是想通过test来调用不同的函数,而test用一个参数就可以,但不同函数的参数是不固定的 可以直接将参数用数组传过去。就是$b。demo只设两个参数就行了。你最好写段完整程序。你这种说法绕来绕去的,我看着很别扭 <?phpfunction takes_array($input){ echo "$input[0] + $input[1] = ", $input[0]+$input[1];}?> 看这个对你有帮助没? 回4楼的function A($a="b",$b="b"){ echo $a." and ".$b;}function B($b="b"){ echo $b;}$exname = "B";$expar = "aa,bb";第一次$$exname($expar);输出结果为"aa,bb"第二次$exname = "A";$$exname($expar);输出结果为"aa,bb and "//当调用A函数时$expar只能当作参数$a传给函数A,但是我想实现效果为$$exname($expar);输出结果为"aa and bb"也就是说把expar的","两边分别传给函数A中的$a 和$b 那用下面的这个肯定能解决的了啊,一个数组参数,判断其长度就行了<?phpfunction takes_array($input){ echo "$input[0] + $input[1] = ", $input[0]+$input[1];}?> 求教一个正则匹配,提取html中href的地址 关于mysql_errno()的奇怪现象 如何检查query()执行是否有错误? php再次时间问题求助 谁知道在php中FCKeditor怎么添加视频按钮 在php中怎样实现response 字符串如何匹配数组和? php4.2.3在win2000+apache2.0下“模块化”安装为什么不成功? 关于php再win98下安装的问题 创建pdo对象时出现Connection failed: could not find driver 字符串替换问题 insert into 与select效率比较
你这种说法绕来绕去的,我看着很别扭
<?php
function takes_array($input)
{
echo "$input[0] + $input[1] = ", $input[0]+$input[1];
}
?>
看这个对你有帮助没?
echo $a." and ".$b;
}
function B($b="b"){
echo $b;
}$exname = "B";
$expar = "aa,bb";第一次
$$exname($expar);
输出结果为
"aa,bb"
第二次
$exname = "A";
$$exname($expar);
输出结果为
"aa,bb and "//当调用A函数时$expar只能当作参数$a传给函数A,但是我想实现效果为
$$exname($expar);
输出结果为
"aa and bb"
也就是说把expar的","两边分别传给函数A中的$a 和$b
<?php
function takes_array($input)
{
echo "$input[0] + $input[1] = ", $input[0]+$input[1];
}
?>