I’m trying to output a newline character in PHP that gets viewed in a web browser. I can only manage it by using the <br /> tag.
When I use \n, nothing occurs, so what is the benefit of using \n? Also what is the benefit of PHP_EOL? When I concatenate it to a string, just a space is printed not a newline.
A web browser interprets the output of a PHP program as HTML, so
\nand\r\nwill not appear to do anything, just like inserting a newline in an HTML file. On the other hand,<br />makes a new line in the interpreted HTML (hence “line BReak”). Therefore,<br />will make new lines, whereas\r\nwill not do anything.