php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #30248 Ternary operator nesting is wrong
Submitted: 2004-09-27 03:02 UTC Modified: 2004-09-27 04:01 UTC
From: RAbbott at CalStateLA dot edu Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.7 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: RAbbott at CalStateLA dot edu
New email:
PHP Version: OS:

 

 [2004-09-27 03:02 UTC] RAbbott at CalStateLA dot edu
Description:
------------
The ternary expression operators '?' and ':' nest improperly.

The issue was reported by abodeman@yahoo as a comment on the Operators page: http://us2.php.net/language.operators.

He reports it as a nuisance.  It's more than that. It is a either an implementation error or an error in the specification of the language.

Here is an example.

<pre>
X = A ? B :
    C ? D :
        E;

parses as if it were written as follows.

X = (A ? B :
    C) ? D :
         E;

It should parse as if it is written like this.

X = A ? B :
    (C ? D :
         E);
</pre>




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-27 04:01 UTC] amt@php.net
This is a known issue, but it's not going to change 
because it will break backwards compatibility. Sorry.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 01:01:33 2025 UTC