Edit report at http://bugs.php.net/bug.php?id=53360&edit=1

 ID:                 53360
 Updated by:         s...@php.net
 Reported by:        torkvemada at nigma dot ru
 Summary:            wrong operator precedence
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Higher precedence implies "tighter binding", so 

var_dump($flag & 3 == 1);

is the same as

var_dump($flag & (3 == 1));

Both of these return

int(0)


Previous Comments:
------------------------------------------------------------------------
[2010-11-19 18:53:17] torkvemada at nigma dot ru

Description:
------------
According to documentation, comparison operators (like ==) have higher
priority than bitwise ones (like &). 

However, the ==operator has higher precedence than &.



It was tested on Debian Squeeze (PHP 5.3.2-1 with Suhosin-Patch) and
Debian Lenny (PHP 5.2.6-1+lenny9 with Suhosin-Patch 0.9.6.2).



Test script:
---------------
$flag = 1;

var_dump($flag & 3 == 1);

var_dump(($flag & 3) == 1);

Expected result:
----------------
bool(true)

bool(true)

Actual result:
--------------
int(0)

bool(true)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53360&edit=1

Reply via email to