Home >Backend Development >PHP Tutorial >PHP assignment operation
Assignment operation:=, which means that the value of the expression on the right is assigned to the operand on the left.
$int1=10; $int1=$int1-6; //$int1=4 echo $int1,"<br>"; $int3=$int2=$int1+4; //右向左,最后$int3=8 echo $int2,"<br>"; echo $int3,"<br>"; $int3=($int2=$int1)+4; //先对()进行运算,再右向左,最后$int3=8 echo $int2,"<br>"; echo $int3,"<br>";
2. Swap the values of two variables
$int_x=10; $int_y=20; $int_x=$int_y+$int_x; $int_y=$int_x-$int_y; $int_x=$int_x-$int_y; echo "<hr>"; echo $int_x,"<br>"; echo $int_y,"<br>";
3. Reference assignment
$x=6;$y=$x;$z=&$y; //means $y, $z Two variables point to the same data