PHP 4.0 Bug #8211 Updated: Incorrect Parsing of <? and ?> tags

From: Date: Tue, 19 Dec 2000 13:40:26 +0000
Subject: PHP 4.0 Bug #8211 Updated: Incorrect Parsing of <? and ?> tags
Groups: php.dev 
Request: Send a blank email to php-dev+get-41864@lists.php.net to get a copy of this message
ID: 8211 Updated by: zeev Reported By: rkenny@mke.catalystwms.com Old-Status: Open Status: Closed Bug Type: Scripting Engine problem Assigned To: Comments: This behavior is by design. The PHP closing tag ?> generates an implicit ; (semicolon), and thus, terminates any statement. For instance: <?php print "foo" ?> will work, because the closing tag will implicitly close the print statement. In your case, when you use <? } ?> to close your IF block, you're also terminating the entire statement, and thus, you cannot use 'ELSE' afterwards: if (...) { ... }; else if { // <-- invalid! ... } Previous Comments: --------------------------------------------------------------------------- [2000-12-12 13:12:18] rkenny@mke.catalystwms.com The following will generate a parse error: <? if ($var == "foo") { ?> <html>some stuff</html> <? } ?> <? else if ($var == "bar" ) { ?> <html>other stuff</html> <? } ?> But this works without error: <? if ($var == "foo") { ?> <html>some stuff</html> <? } else if ($var == "bar" ) { ?> <html>other stuff</html> <? } ?> Any help appreciated. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8211

« previous php.dev (#41864) next »