Plus And Concat Precedence

  • (and -) and . (dot) operators used to have the same priority. Thus, they used to be processed one after the other, from left to right.

In PHP 8.0, the addition has now the highest precedence, and will happen before the concatenation.

PHP code

<?php

echo 35 + 7 . '.' . 0 + 5;

?>

Before

42.5

After

47

PHP version change

This behavior was deprecated in 7.4

This behavior changed in 8.0