学习笔记之测试赋值和赋引用

来源:互联网 发布:关键词 优化 编辑:程序博客网 时间:2024/06/05 15:12

下面是赋值和赋引用的比较:

代码:

$c="123";$d=$c;                             //这里顺便比较下单双引号的区别echo '$c equal to '.$c.'</br>';    //输出:123echo "\$d equal to ".$d."</br>";   //输出:123$c="456";echo '$c equal to '.$c.'</br>';    //输出:456echo "\$d equal to ".$d."</br>";   //输出:123echo '-----------------------</br>';$x="000";$y=&$x;echo "\$x equal to ".$x."</br>";   //输出:000echo "\$y equal to ".$y."</br>";   //输出:000$x="111";echo "\$x equal to ".$x."</br>";   //输出:111echo "\$y equal to ".$y."</br>";   //输出:111

还有个测试++运算符的小例子:

$row=1;echo '$row is '.$row."</br>";//输出:$row is 1$row++;echo "\$row is ".$row;       //输出:$row is 2