Bug #53730 [Opn->Bgs]: mixed classic and new if/else/endif

From: Date: Thu, 13 Jan 2011 01:55:17 +0000
Subject: Bug #53730 [Opn->Bgs]: mixed classic and new if/else/endif
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5791@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53730&edit=1 ID: 53730 Updated by: aharvey@php.net Reported by: max dot wildgrube at web dot de Summary: mixed classic and new if/else/endif -Status: Open +Status: Bogus Type: Bug Package: Documentation problem PHP Version: 5.2.17 Block user comment: N Private report: N New Comment: This is already documented on the alternative syntax manual page, specifically where it says: Note: Mixing syntaxes in the same control block is not supported. Closing. Previous Comments: ------------------------------------------------------------------------ [2011-01-12 20:44:36] max dot wildgrube at web dot de Description: ------------ --- From manual page: http://www.php.net/migration.if-endif --- Parser reports an error even the code is correct: <?php if ( 1 == 2 ): echo 'one is the same as two'; if ( 3 == 3) echo 'liars may tell the truth sometimes'; else: //this is line 5 echo 'one is NOT the same as two'; endif; echo '<br>'; ?> Parse error: syntax error, unexpected ':' in /var/www/web4/html/Kunden/shared_tables/app/test.php on line 5 This can be easily hailed by adding a 2nd ';' after the statement in line 4: ... truth sometimes';; It seems that the parser recognizes 'else:' as 2 syntacital tokens 'else' and ':' instead of one. Hint: the real php version is 5.2.6 - I'm an end-user, no idea about packages. Test script: --------------- <?php if ( 1 == 2 ): echo 'one is the same as two'; if ( 3 == 3) echo 'liars may tell the truth sometimes'; else: //this is line 5 echo 'one is NOT the same as two'; endif; echo '<br>'; ?> Expected result: ---------------- one is NOT the same as two Actual result: -------------- Parse error: syntax error, unexpected ':' in /var/www/web4/html/Kunden/shared_tables/app/test.php on line 27 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53730&edit=1

« previous php.doc.bugs (#5791) next »