Re: can anyone explain this code segment?

From: Date: Tue, 07 Aug 2001 15:21:46 +0000
Subject: Re: can anyone explain this code segment?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-8699@lists.php.net to get a copy of this message
I agree with you. I think the first statment alone is enough. "Hugh Bothwell" <hugh_bothwell@hotmail.com> wrote in message news:20010806183806.16950.qmail@pb1.pair.com... > Apologies for posting to php.windows with a > non-windows-specific question, but I haven't > been receiving php.general for several weeks > now; I assume it went mailing-list-only to lower > the load on the news server?? > > > I've been poking through source to a message-board script, > and came across some code I don't quite understand; > > ... > $text=ereg_replace("<[^>]*>", "", $text); > $text=ereg_replace("^<[^>]*>", "", $text); > $text=ereg_replace("<[^>]*>$", "", $text); > echo $text; > ... > > in context, they are trying to strip any html and/or scripty stuff out > of the body of a message before outputting it. > > The first statement removes '<anything in brackets>', > the second replaces anything in brackets starting at > the beginning of a line... > > Q. Isn't that redundant? Shouldn't the first statement > have removed all the bracket-pairs? In which case, > this statement will never find a set of brackets and > thus does nothing at all?! > > .. and the third removes anything in brackets > followed by a dollars-sign... > > Q. Even more redundant!? There should be no > bracketed stuff left by now! > > > Can anyone figure out the logic behind this?? > >

« previous php.windows (#8699) next »