PHP Assignment Operators With Example

Assignment Operators:

The PHP assignment operators are used with nemeric values to write a value to a variable. The basic assignment operator in PHP is "=".

It means that the left operand gets set to the value of the assignment expression on the right.

List of Assignment Operators


Operator Description Example Is The Same As
= Assign $x = $y $x = $y
+= Add and assign $x += $y $x = $x + $y
-= Subtract and assign $x -= $y $x = $x - $y
*= Multiply and assign $x *= $y $x = $x * $y
/= Divide and assign quotient $x /= $y $x = $x / $y
%= Divide and assign modulus $x %= $y $x = $x % $y


Example:



Result:

10
50
30
125
5
10 

Read Also: