php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16621 different ?: operator precedence then in C
Submitted: 2002-04-15 10:00 UTC Modified: 2010-12-03 17:52 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:3 (37.5%)
Same OS:5 (62.5%)
From: pete at ana dot sk Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.1.2 OS: linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-04-15 10:00 UTC] pete at ana dot sk
Maybe its intentional, but i think that it would be best to have some consitence with C.
1 ? "A" : 1 ? "B" : "C"
return "A" in C (since ?: is associated from right to left)
but it returns "B" in  PHP (since its left to right).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-15 10:28 UTC] pete at ana dot sk
Maybe its intentional, but i think that it would be best to have some
consitence with C.
1 ? "A" : 1 ? "B" : "C"
return "A" in C (since ?: is associated from right to left)
but it returns "B" in  PHP (since its left to right).
 [2010-12-03 17:52 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2010-12-03 17:52 UTC] jani@php.net
Use parenthesis. PHP != C :)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 25 07:02:14 2014 UTC