PHP basic syntax assignment operation

Assignment operation

Assignment operation, we have already learned it.

In mathematics, we call = (an equal sign) an assignment operator, that is, assign the value on the right side of the equal sign to the variable on the left side of the equal sign, and the variable on the left side becomes the value on the right side.

The code runs from top to bottom, so the assignment can be repeated from top to bottom:

<?php

$x = 5;

$x = true;

$x = '爱你';

$x = 12.888;

echo $x;
?>

In the above example, x is repeatedly assigned to different types of values. We have studied the above many times.

Then there are several assignment operators in PHP:

##/=$x /= $ y$x = $x / $y%=$x %= $y$x = $x % $y.=$x .= $y#$x = $x . $y
SymbolExampleEquivalence
+=$x += $y$x = $x + $y
-=#$x -= $y$x = $x - $y
*=$x *= $y$x = $x * $y
The above examples and equivalent equations are clearly explained.

$x += $y is equivalent to $x = $x + $y

<?php

$x = 5;

$y = 8;

$x += $y;

echo $x;
?>

Just remember all the above. These are all grammatical rules, nothing much to say.


Continuing Learning
||
<?php $x = 5; $y = 8; $x += $y; echo $x; ?>
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!