php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53730 mixed classic and new if/else/endif
Submitted: 2011-01-12 20:44 UTC Modified: 2011-01-13 02:55 UTC
From: max dot wildgrube at web dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.17 OS:
Private report: No CVE-ID: None
 [2011-01-12 20:44 UTC] 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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-12 23:22 UTC] felipe@php.net
-Package: *General Issues +Package: Documentation problem
 [2011-01-13 02:55 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-01-13 02:55 UTC] aharvey@php.net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Feb 25 00:01:26 2020 UTC