passing by reference与 passing by value的区别
如下一段程序:
<html>
<title>xxx.php</title>
<?
//first program
echo 'passing by reference:<br>';
function doo(&$bar)
{
$bar .='and something extra.';
}
$str='this is a string';
doo($str);
echo $str;
echo '<p>';
//secend function
echo'passing by value :';
function doo2($bar)
{.
$bar.='and something extra.';
}
$str='this is a string,';
doo2($str);
echo'<br>',$str;
doo2(&$str);
echo'<br>',$str;
?></html>
输出结果是:
passing by reference:
this is string,and something extra.
passing by value:
this is a string, and something extra
造成这样结果的诀窍是什么??doo2($str)与doo2(&$str)有什么不同?