Oh flipping 'eck. I think just discovered a bug in PHP.
I've got a script featuring the following regex:
For those of you who don't read Perl regexs, that's looking for a < followed by a minimal number of non-> characters, followed by a >. It's then replacing it with "". Nice simple way to rip out all HTML tags. As some of you will already have noticed, the ? isn't needed since the match will end at the > regardless of what else I tell it.
All is fine, however don't comment that line out. Why not? Well, because php sees the ?> as the end of the PHP. If you're inside an if/while/whatever nest then you get an error that the brackets don't match. If you're not inside brackets it dumps all following text to screen.
EDIT I know how to fix it (ripping the ? out leaves a regex that does exactly the same thing) I'm just amused and bemused that it causes problems.
I've got a script featuring the following regex:
$body = preg_replace("|<[^>]*?>|i","",$body);For those of you who don't read Perl regexs, that's looking for a < followed by a minimal number of non-> characters, followed by a >. It's then replacing it with "". Nice simple way to rip out all HTML tags. As some of you will already have noticed, the ? isn't needed since the match will end at the > regardless of what else I tell it.
All is fine, however don't comment that line out. Why not? Well, because php sees the ?> as the end of the PHP. If you're inside an if/while/whatever nest then you get an error that the brackets don't match. If you're not inside brackets it dumps all following text to screen.
EDIT I know how to fix it (ripping the ? out leaves a regex that does exactly the same thing) I'm just amused and bemused that it causes problems.
