Re: nl2br and <br />
| From: | Bobby Patel | Date: | Fri, 27 Jun 2003 21:15:10 +0000 |
| Subject: | Re: nl2br and <br /> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153216@lists.php.net to get a copy of this message | ||
Since I haven't had any problems with <br /> I really don't care. However,
if you are concerned why don't you write a function like this:
my_nl2br($targetStr, XML = true) {
$buffer = '';
if (XML) {
return nl2br($targetStr);
}
else {
$buffer = nl2br($targetStr);
$buffer = str_replace ('<br />', '<br>', $buffer );
return $buffer
}
}
You might be able to call the function nl2br but I am sure you will get a
function name class or "function re-declartion error", but if you are doing
some OOP then you may be able to overide that.
Maybe this is not the post you were looking for, anyways my 2 cents.
Bobby
"Raymond C. Rodgers" <phpml@bbnk.dhs.org> wrote in message
news:1056748028.25687.35.camel@wolverine.bbnk...
> 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/
>