note 15468 added to control-structures.alternative-syntax

From: Date: Wed, 12 Sep 2001 13:43:16 +0000
Subject: note 15468 added to control-structures.alternative-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-17934@lists.php.net to get a copy of this message
The following code will fail: if ( true ) : ___ echo "yes"; ___ if ( ! false ) echo ", of course"; else : ___ echo "no"; endif; Will fail with syntax error, cause the interpreter 'thinks', that the "else:" belongs to the "if (!false)". Use {}-syntax instead or use consequently ___ if (!false) : echo ", of course!"; endif; Avoid to mix "if :"-syntax with {}- or single-statement-syntax. Comment: This bogus could be fixed, if it wouldn't be allowed to mix "if {}"- or "if-single-statement" with "if :"-statements (makes sense in my eyes). http://www.php.net/manual/en/control-structures.alternative-syntax.php

« previous php.notes (#17934) next »