Re: nl2br and <br />
| From: | Lars Torben Wilson | Date: | Sat, 28 Jun 2003 02:57:24 +0000 |
| Subject: | Re: nl2br and <br /> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153242@lists.php.net to get a copy of this message | ||
On Fri, 2003-06-27 at 14:07, Raymond C. Rodgers wrote:
> I'm sure that this has probably been discussed before, but I couldn't
> seem to find any direct references to such a discussion. The line break
> tags that nl2br() produces have the forward slash embedded in them,
> which is not in the HTML 4.x standard. While this isn't a big deal
> really, the fact of the matter is that web browsers built to the
> specifications of the W3C HTML 4.x standards may not like this. In fact
> the W3C HTML validator reports this as an error.
>
> I read on the function description page that this is apparently an XHTML
> curiosity. Would it be possible for someone to add an optional flag to
> nl2br() to specify HTML rather than XHTML compliance? For instance, a
> call to nl2br() without XHTML compliance might look like this:
>
> $mystring=nl2br($myotherstring,false);
>
> For compatibility's sake, maybe default the flag to true and make the
> flag optional. If unspecified, the call to nl2br() would continue to
> function as it always has. However if specified, and set to false, the
> function would return the HTML compliant break tag <br>.
>
> Thoughts? Comments?
> --
> Raymond C. Rodgers
> http://bbnk.dhs.org/~rrodgers/
> http://www.j-a-n.net/
Hi there,
This has actually been beaten to death over the years. One place to
start reading in the archives:
http://marc.theaimsgroup.com/?l=php-dev&w=2&r=1&s=nl2br+AND+xhtml&q=b
This will give links to some discussions and a few bug reports on the
topic.
Anyway, the argument goes something like this: <br> is not XHTML
compliant, but <br /> is. There are browsers which do not like <br/>,
but all are supposed to ignore unrecognized attributes, which is what
the / gets interpreted as when there is a space before it--which is why
<br /> is output instead of <br/>.
To my knowledge, in the 3 years of sporadic debate on the topic, nobody
has yet come forward with a demonstration of a browser which incorrectly
handles <br />.
If you're having trouble validating, see if using html 4 transitional
helps any. Otherwise, the function is easily doable yourself in a
couple of lines of code.
However, if you read all that and still think you've got a shot at
changing the minds of the dev team, feel free to open a new feature
request bug report in the bug database at http://bugs.php.net.
Note that
I'm not going to argue for or against. :)
Hope this helps,
Torben
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----