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:
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:
Symbol | Example | Equivalence |
---|---|---|
+= | $x += $y | $x = $x + $y |
-= | #$x -= $y | $x = $x - $y |
*= | $x *= $y | $x = $x * $y |
$x /= $ y | $x = $x / $y | |
$x %= $y | $x = $x % $y | |
$x .= $y | #$x = $x . $y |
$x += $y is equivalent to $x = $x + $y