We assign values to variables with assignment operators. The base assignment operator is equal (=). I assume that you understand this in the examples and narratives that pass. A single equal sign allows us to assign the desired value to the desired variable.

Let’s show the other operators on a table. These operators are unified assignment operators. These add a value to the end of a variable or make it easier for us to add a number to the result in the variable. Here are a few examples of the combined assignment operators that we can comprehend with a simple example:

Operator Name Example
+ Addition $a + $b
Subtraction $a - $b
* Multiplication $a * $b
/ Division $a / $b
% Module $a % $b

Using an example assignment operator:

<?php
$a = 10;
$b = 20;
$a += $b;

echo $a;
?>

It will display 30. We added the value of the variable and assigned to the value of the existing variable using the combined assignment operator.

This combined assignment operator makes it easier for us not to reprint the same variable for the values we add or subtract at the end of the variable.