Why have 2 functions that does the same thing? They both add a linebreak.
Any diffrence between them?
The /r stands for return or carriage return which owes it's history to the typewriter. A carriage return moved your carriage all the way to the right so you were typing at the start of the line. The /n stands for new line, again, from typewriter days you moved down to a new line.
"\r" is Carriage return. Mind the double quotes when you use it with PHP! If you use single quotes, You will get the string \r instead of a line break. BTW, it is suitable to use "\r\n" if you want to put a line break in your text so it will be rendered correctly in different operating systems.
\n means new line. It means that the cursor must go to the next line. \r means carriage return. It means that the cursor should go back to the beginning of the line.
Answer: Use the Newline Characters ' \n ' or ' \r\n ' You can use the PHP newline characters \n or \r\n to create a new line inside the source code. However, if you want the line breaks to be visible in the browser too, you can use the PHP nl2br() function which inserts HTML line breaks before all newlines in a string.
This has nothing to do with PHP, and is a consequence of history :
\n
for linebreaks\r
PHP has just kept that behavior -- so it can work with those different OSes and their files.
Also, note :
\r
is Carriage return
\n
is Newline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With