Operator Example Action
+= $a += 3; Changes the value of a variable
variable to the current value
plus the value on the right side.
-= $a -= 3; Changes the value of a variable
to the current value minus the
value on the right side.
.= $a .= “string”; Concatenates (adds on to)
the value on the right side with
the current value.
Example:
<HTML>
<HEAD>
<TITLE>Using Assignment Operators</TITLE>
</HEAD>
<BODY>
<?
$origVar = 100;
echo “<P>Original value is $origVar</P>”;
$origVar += 25;
echo “<P>Added a value, now it’s $origVar</P>”;
$origVar -= 12;
echo “<P>Subtracted a value, now it’s $origVar</P>”;
$origVar .= ” chickens”;
echo “<P>Final answer: $origVar</P>”;
?>
</BODY>
</HTML>