When Space Matters

<?php

echo 10 / 1 . ' ms ';
echo 10 / 2 .' ms ';

//Parse error: syntax error, unexpected single-quoted string " ms ", expecting "," or ";"
echo 10 / 3. ' ms ';

//Parse error: syntax error, unexpected single-quoted string " ms ", expecting "," or ";"
echo 10 / 4.' ms ';

// OK again
echo 10 / 5.6. ' ms ';

The two first echo are valid, because there is a space between the integer and the dot : PHP interpret them as a concatenation.

The third and fourth ones are a syntax error, because PHP starts interpreting a float, but fail to get the decimal part.

Finally, the last echo is valid, because PHP managed to build a float, so it doesn’t mistake the second point with another float, and use it as a concatenation.

Some edge cases of white space matters in the syntax.

See Also

PHP Features

Last updated: 14 July 2026