[Solar-talk] retain line breaks/newline

Rodrigo Moraes rodrigo.moraes at gmail.com
Thu Aug 3 05:37:19 PDT 2006


On 8/3/06, Jeff Surgeson wrote:
> Hmm sorry being thick as usual, I need to convert ascii \r\n with a <br />
> tag, so back tothe same problem of allowing html tags and escape()

Jeff,
- *use* escape to display any input from outside, *always*.
- To convert \n to <br />, use the function nl2br().
- If you want to allow some other html tags, you have to use a
different filter, not escape() which will transform all tags using
htmlspecialchars().
- I think it is better to store \n but not <br /> in the database;
this will be better if you want to output nice XHTML, putting each
line inside <p>'s, for example.

rodrigo


More information about the solar-talk mailing list