can anyone explain this code segment?
| From: | Hugh Bothwell | Date: | Mon, 06 Aug 2001 18:40:47 +0000 |
| Subject: | can anyone explain this code segment? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-8686@lists.php.net to get a copy of this message | ||
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??