Req #16621 [Opn->Wfx]: different ?: operator precedence then in C
| From: | jani@php.net | Date: | Fri, 03 Dec 2010 16:52:15 +0000 |
| Subject: | Req #16621 [Opn->Wfx]: different ?: operator precedence then in C | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156736@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=16621&edit=1
ID: 16621
Updated by: jani@php.net
Reported by: pete at ana dot sk
Summary: different ?: operator precedence then in C
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: linux
PHP Version: 4.1.2
Block user comment: N
Private report: N
New Comment:
Use parenthesis. PHP != C :)
Previous Comments:
------------------------------------------------------------------------
[2002-04-15 10:28:04] 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).
------------------------------------------------------------------------
[2002-04-15 10:00:43] 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).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=16621&edit=1