ID: 50173 Updated by: bj...@php.net Reported By: kevinarcher15 at hotmail dot com -Status: To be documented +Status: Closed Bug Type: Scripting Engine problem Operating System: CentOS 5 PHP Version: 5.3.0 New Comment:
This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2009-11-23 21:11:37] s...@php.net Automatic comment from SVN on behalf of bjori Revision: http://svn.php.net/viewvc/?view=revision&revision=291231 Log: Fixed bug#50173 (Alternative Syntax Else Issue) ------------------------------------------------------------------------ [2009-11-14 21:23:24] j...@php.net 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 ------------------------------------------------------------------------ [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