note 10366 added to Alternative syntax for control structures
| From: | justin at iqmail dot net | Date: | Fri, 29 Dec 2000 20:03:08 +0000 |
| Subject: | note 10366 added to Alternative syntax for control structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9195@lists.php.net to get a copy of this message | ||
This is also relevant when mixing styles and interspersing PHP with HTML. The following example
gives a syntax error since it associates the else with the inner if.
<?php
if (condition):
// code
if (another_condition) {
// multi-line code
}
else:
?>
[html here]
<?php
endif;
?>
A way around this is to not mix syntax, and change the inner if to the alternate colon-based syntax.
-jcl-
http://www.php.net/manual/control-structures.alternative-syntax.php