ID: 50173 Updated by: j...@php.net Reported By: kevinarcher15 at hotmail dot com -Status: Open +Status: To be documented Bug Type: Scripting Engine problem Operating System: CentOS 5 PHP Version: 5.3.0 New Comment:
Do not mix the syntax. You're not only confusing the engine, you're confusing yourself as well. Needs a note in the manual page here: http://www.php.net/manual/en/control-structures.alternative-syntax.php Previous Comments: ------------------------------------------------------------------------ [2009-11-14 02:38:25] kevinarcher15 at hotmail dot com Description: ------------ PHP is confusing else as part of the nested if statement above it. When removing the colon and replacing it with a left brace { it says unexepected '{' expecting ':'... Placing any line of code below the nested if will stop the problem from occurring, even while(false) { } prevents it. So it makes sense why its happening, however based on the syntax and alternative syntax it looks acceptable and PHP even seems to have an idea that the else is part of the alternative syntax. Test on stable 5.3.0 and 5.3.1-dev (August 15 2009). Reproduce code: --------------- if(true): if(true) { echo 'exepected'; } else: echo 'not here'; endif; Expected result: ---------------- expected Actual result: -------------- PHP Parse error: syntax error, unexpected ':' in /home/archer/test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50173&edit=1