The += sign is called the Additional Assignment Operator. It adds the value on the right side to the variable on the left side and stores the result in the same variable.
Syntax:
$variable += value;
Example:
<?php
$x = 10;
$x += 5; // adds 5 to $x, now $x is 15
?>
Above, the example works like a Gullak(piggy bank)
There are some coins inside. Every day, kids add some more coins. After a few days, you will get more coins.
By the graphical representation:
old value->[10] new value->[5]
variable -> a a
| |
add
|
10 + 5 = 15
|
The final result assigned in -> a = 15
Output:
15
