RE: [PHP] nl2br returns <BR />? normality or a bug?

From: Date: Sun, 07 Apr 2002 00:41:22 +0000
Subject: RE: [PHP] nl2br returns <BR />? normality or a bug?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91896@lists.php.net to get a copy of this message
Thanks Torben, I have rushed into this discussion because I didn't know anything about this change. Later on I've discovered the rest. Thank you all. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com > -----Original Message----- > From: Lars Torben Wilson [mailto:torben@pinc.com] On Behalf Of Lars Torben Wilson > Sent: Saturday, April 06, 2002 10:30 PM > To: Justin French > Cc: php > Subject: Re: [PHP] nl2br returns <BR />? normality or a bug? > > On Fri, 2002-04-05 at 18:34, Justin French wrote: > > on 06/04/02 11:05 AM, Maxim Maletsky (subscriptions@phpbeginner.com) wrote: > > > > > You're deadly wrong, Justin. Years of coding and I have never seen this > > > behavior of nl2br(). Perhaps I missed its new behavior's introduction > > > (guilty as charged if so) but I only remember it returning me <BR> not > > > <BR>. I have several regex depending on it. > > 'Deadly' wrong? Wow. > > > Well, I've been at this PHP thing for 2 years, and like I said, "for as long > > as *I* can remember, it's been <BR />". Perhaps it was introduced in PHP4, > > perhaps earlier. I was not an in depth user of PHP3. > > Justin is right on this one. This was changed on Dec 27, 2000. So it's > been around for quite a long time. > > It was added because it's valid XML *and* valid HTML. It is true that > some browsers will not correctly interpret <br/> (note the lack of a > space before the /) but everything I've ever tested has been just fine > with <br />. As they should. > > This has been discussed a zillion times on the mailing lists. Maxim, you > could have found lots of background on the change by searching the list > archives (http://marc.theaimsgroup.com) the bug database > (http://bugs.php.net) and the CVS repository (http://cvs.php.net). Some > links which may explain things a bit better: > > A thread on the topic: > http://marc.theaimsgroup.com/?l=php-dev&m=99321596031773&w=2R > �×Cî�æØ_Ø[U > > The CVS entry itself: > http://cvs.php.net/diff.php/php4/ext/standard/string.c?r1=1.176&r2=1.177 > > > Torben > > > But I can't be "deadly wrong" :) > > > > > > > False! > > > > > > It DOES NOT work fine in every browser. I'd love to give you a prov, but > > > because I am lazy I will just tell you this formula: > > > > > > > > > if("I found this issue"=="I noticed screwed pages on my site") { > > > All I did: preg_replace("<BR[^>]*>", "<BR>", > > > $text); { > > > ...and pages became pretty again. > > > } > > > } > > > > > > /// preg 'couse I had no idea what comes up next :-) > > > > Again. I was only stating MY experience. "Every browser I can get my hands > > on". I do extensive testing, and have never seen a <BR> or <BR/> or <BR /> > > misbehave. > > > > If you have seen it perform unexpectedly, I'm keen to hear about. > > > > > > In fact, if this is the case, then I'll be writing my own nl2br function > > which returns a <br>, to avoid this problem ever again. > > > > > > Perhaps in future releases, nl2br() should have an option flag for switching > > between XHTML and HTML? I can't see why the powers that be would have > > included XHTML compliance if it wasn't backwards compatible. > > > > > > > > > when was it changed? Is there any reference? > > > > I went to php.net/nl2br and this line of text was in there: > > > > "Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions > > before 4.0.5 will return string with '<br>' inserted before newlines instead > > of '<br />'." > > > > :) > > > > So it would appear that I've only been using nl2br since I got my hands on > > PHP4.05+, which according to the earliest date I can find, was released > > sometime around 2001-04-30. > > > > > > > > Justin French > > -------------------- > > Creative Director > > http://Indent.com.au > > -------------------- > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > Torben Wilson <torben@php.net> > http://www.thebuttlesschaps.com > http://www.hybrid17.com > http://www.inflatableeye.com > +1.604.709.0506 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#91896) next »