[Solar-talk] retain line breaks/newline

Jeff Surgeson solar at 3hex.com
Thu Aug 3 06:21:27 PDT 2006


> > 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()

> - *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.

Thanks! makes sense.

-- 
Jeff Surgeson


More information about the solar-talk mailing list