note 68902 deleted from control-structures.elseif by felipe
| From: | felipe@php.net | Date: | Tue, 29 Jan 2008 11:12:50 +0000 |
| Subject: | note 68902 deleted from control-structures.elseif by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135503@lists.php.net to get a copy of this message | ||
Note Submitter: jsimlo
----
This example generates a parse error:
<?
if ($a==1):
/* nested if */
if ($b==1) echo "2";
elseif ($a==3):
/* other code */
endif;
?>
The nested "if" binds to the outer "elseif" and the colon the generates an
error: syntax error, unexpected ':'.
According to http://bugs.php.net/bug.php?id=838
this "bug" is not going to be fixed. Beware.
An "artful" sollution to this bug could look like this:
<?
if ($a==1):
/* nested if */
if ($b==1) echo "2";
/* dummy expression */
;
elseif ($a==3):
/* other code */
endif;
?>