0

In a lot of PHP tutorials, I have seen that the use of carriage return.

"/n" and "/r"

But Im very curious why we cannot just use echo "<br>" tag?

1 Answers1

1

<br> is a new line in on a HTML page (an will display as such for the view on any web page). \n and \r are used more for the 'formatting' of the HTML code itself and will show on a single line for the viewer.

In a text area, however, \n or \r will show as a new line, whereas a <br> would not. \n or \r could also be used within strings for scripts that don't allow carriage returns such as javascript.

Nathan Stockton
  • 292
  • 1
  • 5
  • 1
    there's also files which when written to, will write each dataset onto a new line, given the OS. `\n` is for \*NIX and `\n\r` for Windows. PHP_EOL is cross-platform. – Funk Forty Niner Aug 04 '18 at 13:01