From: kevinarcher15 at hotmail dot com Operating system: CentOS 5 PHP version: 5.3.0 PHP Bug Type: Scripting Engine problem Bug description: Alternative Syntax Else Issue
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 bug report at http://bugs.php.net/?id=50173&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50173&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50173&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50173&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50173&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50173&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50173&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50173&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50173&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50173&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50173&r=support Expected behavior: http://bugs.php.net/fix.php?id=50173&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50173&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50173&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50173&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50173&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50173&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50173&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50173&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50173&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50173&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50173&r=mysqlcfg