note 10366 modified in control-structures.alternative-syntax by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 19:20:18 +0000 |
| Subject: | note 10366 modified in control-structures.alternative-syntax by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25236@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-
--was--
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/en/control-structures.alternative-syntax.php