Shorthand unary operators
The = operator is special in that you can combine it with other operators. For example, to turn > (greater than) into greater than or equals, add the equals sign to the end - >=. You can add an equals sign to each of the first six operators in the list, forming +=, -=, *=, /=, and .=, and these become unary operators, like this:
<?php
$somevar = 5;
$somevar += 5; // $somevar is now 10
$somevar *= 2; // $somevar is now 20
$somevar .= " elephants"; // $somevar is now "20 elephants"
?>
The unary versions of these operators are really just shorthand, but they are a little easier to read also.



Copyright 2012 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK