php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #45223 else if (...): unexpected T_IF, expecting ':'
Submitted: 2008-06-09 20:44 UTC Modified: 2008-06-24 18:54 UTC
From: ms419 at freezone dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: N/A OS: N/A
Private report: No CVE-ID: None
 [2008-06-09 20:44 UTC] ms419 at freezone dot co dot uk
Description:
------------
PHP documentation claims:

"In PHP, you can also write 'else if' (in two words) and the behavior would be identical to the one of 'elseif' (in a single word). The syntactic meaning is slightly different (if you're familiar with C, this is the same behavior) but the bottom line is that both would result in exactly the same behavior." - http://php.net/elseif

However I get the following error:

Parse error: syntax error, unexpected T_IF, expecting ':' in /home/jablko/public_html/test.php on line 3

Reproduce code:
---------------
<?php if (false): ?>
  AAA
<?php else if (true): ?>
  BBB
<?php else: ?>
  CCC
<?php endif; ?>


Expected result:
----------------
BBB

Actual result:
--------------
Parse error: syntax error, unexpected T_IF, expecting ':' in /home/jablko/public_html/test.php on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-10 08:45 UTC] mgf@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Well, you\'ve just proved that \"else if\" is *not* identical to \"elseif\"!  The error message is self-explanatory.
 [2008-06-10 08:49 UTC] mgf@php.net
Oh, I beg your pardon -- responded too quickly and with insufficient coffee level!

Looks like a documentation problem to me, and will be specific to the alternative ":"-style syntax.
 [2008-06-24 18:54 UTC] danbrown@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC