下面是赋值和赋引用的比较:
代码:
$c="123";
$d=$c; //这里顺便比较下单双引号的区别
echo '$c equal to '.$c.'</br>'; //输出:123
echo "\$d equal to ".$d."</br>"; //输出:123
$c="456";
echo '$c equal to '.$c.'</br>'; //输出:456
echo "\$d equal to ".$d."</br>"; //输出:123
echo '-----------------------</br>';
$x="000";
$y=&$x;
echo "\$x equal to ".$x."</br>"; //输出:000
echo "\$y equal to ".$y."</br>"; //输出:000
$x="111";
echo "\$x equal to ".$x."</br>"; //输出:111
echo "\$y equal to ".$y."</br>"; //输出:111
还有个测试++运算符的小例子:
$row=1;
echo '$row is '.$row."</br>";//输出:$row is 1
$row++;
echo "\$row is ".$row; //输出:$row is 2