#49019 [Opn->Fbk]: order of operations is not valid for assignment in all cases
| From: | jani@php.net | Date: | Wed, 22 Jul 2009 20:15:52 +0000 |
| Subject: | #49019 [Opn->Fbk]: order of operations is not valid for assignment in all cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140081@lists.php.net to get a copy of this message | ||
ID: 49019
Updated by: jani@php.net
Reported By: michaeldnelson dot mdn at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: freebsd
PHP Version: 5.2.10
New Comment:
= is associated on right, || is associated on left, so that's exactly
what your code does..
Previous Comments:
------------------------------------------------------------------------
[2009-07-22 17:10:36] michaeldnelson dot mdn at gmail dot com
Description:
------------
It appears = has a higher precedence than || in some situations which
is contrary to the manual. This exception is not noted as far as I can
tell.
var_dump(!$test = false || !$test2 = false);
is being interpreted like this
var_dump(!$test = (false || !$test2 = false));
instead of like this
var_dump((!$test = false) || (!$test2 = false));
If I missed something my apologies.
Thanks,
Michael D. Nelson
Reproduce code:
---------------
---
From manual page: language.operators.precedence
---
var_dump(!$test = false || !$test2 = false);
echo "TEST\n";
var_dump($test);
echo "TEST2\n";
var_dump($test2);
Expected result:
----------------
bool(true)
TEST
bool(false)
TEST2
NULL
Actual result:
--------------
bool(false)
TEST
bool(true)
TEST2
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49019&edit=1