look at this:
<?php
echo "<p>this is my <a href='#'>\nlink1\n</a>\n, <a href='#'>\nlink2\n</a>\n, <a href='#'>\nlink3\n</a>\n and <a href='#'>\nlink4\n</a>\n!</p>\n";
?>
OUTPUT:
this is my link1 , link2 , link3 and link4 !
INSTEAD OF:
this is my link1, link2, link3 and link4!
WHY IS THIS?
there are unwanted spaces between “link1” and “,” or “link4” and “!”.
and also interesting is the fact that if there is a space after the “\n” .. it works.
this really disturbs my work (and workflow).
How to avoid this bug/mistake?
The observed behaviour is not a bug; it is exacty as defined in the HTML standard.
When your browser sees a newline, it is interpeted as a whitespace. (whitespace is visualized as a space character).
if your browser sees multiple (consecutive) whitespaces, it only will display a single space.
If you do not want spaces to be displayed for newlines, remove the newlines before
echo-ing the string to the browser: