by jiggy2011 · 13y ago · 0 comments
Seems to do what it says on the tin.
Plus the actual HTML-escaping tools (htmlspecialchars, htmlentities) do not make whitespace significant.
Though these days, you might arguably be better off with "white-space: pre-line" in CSS instead.
It's only safe and reliable as a part of nl2br(htmlspecialchars()) combo, so a function that does both could have been a better idea.
The function never purports to do anything other than convert newlines to BR tags.
I don't see how that's implied at all. After all, the function is named nl2br, not html2text.
Removing it would simply cause newbies to have to wrange with str_replace to build trivial web apps.
Prior to 4.0.5, it used "<br>". As of 4.0.5, they switched to "<br />". (As of 5.3.0, they did the obvious thing and added a second parameter, is_xhtml).
This isn't an isolated incident -- any minor update is liable to change how a function works or what parameters it can take. So you're better off writing it yourself (or doing it inline with a string replace or regular expression).