时间:2021-07-01 10:21:17 帮助过:17人阅读
function sum($p)
{
return $p.='aaa';
}
function &sum2($p)
{
return $p.='bbb';
}
echo sum($a);
echo "
";
echo sum2($b);
$a = 'wap';
$b ='kkk';
function sum($p)
{
return $p.='aaa';
}
function &sum2($p)
{
return $p.='bbb';
}
echo sum($a);
echo "
";
echo sum2($b);
我已经在你的另一个问题中回答了你的相关提问,在此例中,如果想进行比较,你可以将代码修改为:
$a = 'wap';
$b ='kkk';
function sum($p)
{
return $p.='aaa';
}
function &sum2(&$p)
{
return $p.='bbb';
}//既然是返回引用,自然不能使用形参传递,所以将$p改为&$p
echo sum($a);//output is wapaaa
echo "
";
echo sum2($b);//output is kkkbbb
echo "
";
echo sum($a);//output is wapaaa
echo "
";
echo sum2($b);//output is kkkbbbbbb