I know it is possible in php to concatenate two strings like
$a .= $b;
which is equal to
$a = $a . $b;
Is it possible to do something with integers? but with math operations? I have two variables:
$var1 = 8;
$var2 = 2;
I need to do $var1 - $var2, but I don’t want to create third variable to hold this calculation. I would try $var1 = $var1 + $var2 will this work? Is there another .= similar way of doing it?
As in C and C++, PHP supports
Compound_assignment_operators:So, the line:
$var1 = $var1 + $var2;is equivalent to:
$var1 += $var2;For full list of those operators, take a look at Compound_assignment_operators