It’s not JS, .
will not sum up numbers, but convert it to string
$d = $a . $b . $c;
Please note, that you are working with float numbers, so sometimes instead of 1200.00
you can get 1199.999999999999999999998
and outputting it will trim your .00
part.
That’s why you need to use number_format()
to output floats in format that you want:
function getFloatStr(float $num) {
return number_format($num, 2, '.', '');
}
$d = getFloatStr($a) . $b . getFloatStr($c);
3
solved How to put multiple parameters in one $ [closed]