note 102151 deleted from control-structures.else by danbrown

From: Date: Sun, 30 Jan 2011 01:20:36 +0000
Subject: note 102151 deleted from control-structures.else by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176504@lists.php.net to get a copy of this message
Note Submitter: sudo ---- Larry H-C's example is syntactically incorrect, that's why it doesn't work. It has nothing to do with dropping out into HTML mode. His code is equivalent to: <?php if ($condition) { doSomething(); } // putting any code here, even HTML, will cause an error, because when the interpreter reaches the "else" on the next line, it will be completely out of context and it won't know what to do with it. else { doSomethingElse(); } ?> In other words, an if...else construct is a single entity - you can't go shoving code into the middle of it willy-nilly. I hope this avoids potential confusion.

« previous php.notes (#176504) next »