RE: [PHP] \n and <br>
| From: | Chris Hayes | Date: | Mon, 10 Nov 2003 13:20:29 +0000 |
| Subject: | RE: [PHP] \n and <br> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169027@lists.php.net to get a copy of this message | ||
\n is the code to write a new line, between "double quotes". Actually it translates to a 0D or 0A code. If there is a 0D or 0A in a text or file (or normal text email) it works as a newline. If you look at the _source_ of your HTML file you will see it too.
<BR> is the HTML code for new line. Browsers understand only <BR> (well and <P> and H1-6> also cause a new line), they are taught to ignore the 0A and 0D.
If you have a piece of text coming in from a textarea or database, it usually will have the \n type code. To show such texts in a HTML page you have to translate the \n to <BR>. Because this is so common, PHP has the function nl2br(). If you pronounce this say: "NewLine To BReak".