In programming it is a very common task to have how to increment a variable by some fixed amount. The most common example of this is a counter.Say you want to increment a counter by 1, you would have:

* $counter = $counter + 1;

However, there is a shorthand for doing this.

* $counter += 1;

This combination assignment/arithmetic operator would accomplish the same task. In general, “+=” and “-=” are the most widely used combination operators.

+= Plus Equals
-= Minus Equals
*= Multiply Equals
/= Divide Equals
%= Modulo Equals
.= Concatenate Equals

$a=5;
echo $a+=5;

eXTReMe Tracker