Bug #17180 Updated: Operator Precedence
| From: | derick@php.net | Date: | Thu, 16 May 2002 17:27:03 +0000 |
| Subject: | Bug #17180 Updated: Operator Precedence | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-7856@lists.php.net to get a copy of this message | ||
ID: 17180
Updated by: derick@php.net
Reported By: sitnikov@infonet.ee
Status: Analyzed
-Bug Type: Scripting Engine problem
+Bug Type: Documentation problem
PHP Version: 4.2.0
New Comment:
Marking this as a doc problem.
Previous Comments:
------------------------------------------------------------------------
[2002-05-14 13:46:58] phpclub@digiways.com
Actually this is a bug, since in PHP manual it's clearly stated that !
operator has a priority over = operator.
> It makes no sense to assign anything to NOT(a variable),
> so PHP takes care of that by
> changing the precedence a little in this case.
In other words - if user makes a mistake and writes illegal code, PHP
takes care about that and makes this code work (but in a way different
from what developer has expected).
Also if you consider any other programming languages,
if you write a code which should not compile by language specifications
(like the above code in PHP), no compiler will try to "take care" of
that.
If you insist on that "care", then you definetely have to reflect that
in the manual, otherwise it's nothing but a bug.
------------------------------------------------------------------------
[2002-05-13 18:30:31] sitnikov@infonet.ee
This behaviour is capable to confuse the developer and if this is
"features" it must be documented in manual.
------------------------------------------------------------------------
[2002-05-13 18:20:14] manuzhai@php.net
Well, but it's stupid to do something like that. It makes no sense to
assign anything to NOT(a variable), so PHP takes care of that by
changing the precedence a little in this case.
------------------------------------------------------------------------
[2002-05-13 17:56:54] sitnikov@infonet.ee
Yes, I want ASSIGN value to $a and check assigned value.
But parser must say: "parser error", becouse it can not assign value to
constant.
Please reopen.
------------------------------------------------------------------------
[2002-05-13 17:48:54] manuzhai@php.net
"if (!$a = foo(FALSE))" --> you're assigning the output of foo(FALSE)
to $a
"if (!$a == foo(FALSE))" --> you're comparing !$a and foo(FALSE)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/17180
--
Edit this bug report at http://bugs.php.net/?id=17180&edit=1