note 107424 deleted from control-structures.elseif by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 21:16:36 +0000 |
| Subject: | note 107424 deleted from control-structures.elseif by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187867@lists.php.net to get a copy of this message | ||
Note Submitter: lmeurs
----
As Vladimir Kornea stated, this does not work:
<?php
if($a):
echo $a;
if($b) {
echo $b;
}
else:
echo $c;
endif;
?>
But when you put a semicolon after the inner if, PHP knows that the following else belongs to the
outer if. Like this:
<?php
if($a):
echo $a;
if($b) {
echo $b;
}; // <- closing semicolon
else:
echo $c;
endif;
?>