Operator precedence 101. The +
and .
operators have the same precedence and left-to-right associativity, so without braces the operations are evaluated from left to right.
Consider this example which I've adapted from your question's code:
$x = 3;
$y = 5;
echo "$x+$y=" . $x + $y;
Variable names inside double quotes will be expanded (a.k.a. string interpolation) so it is evaluated as follows:
echo "3+5=" . 3 + 5;
echo ("3+5=" . 3) + 5; //added braces to demonstrate actual operations order
echo "3+5=3" + 5;
echo 3 + 5; //string evaluated in numeric context is coerced to number¹
echo 8;
In the question's original code there's one more string concatenation which will concatenate this result with another string and that's it.
¹ From PHP docs:
The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits.
And of course, you can always use braces to force operations' precedence in order to get the desired result.