ID:               49637
 Updated by:       ras...@php.net
 Reported By:      erik at ruigekonijnen dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Variables related
 Operating System: Windows XP
 PHP Version:      5.3.0
 New Comment:

&& has higher precedence than =
so it is working as expected and as documented at
http://php.net/manual/en/language.operators.precedence.php




Previous Comments:
------------------------------------------------------------------------

[2009-09-23 08:01:49] erik at ruigekonijnen dot nl

Description:
------------
When you assign a new variable directly into an IF statement, it is not

updated if you try to read from it in the same statement.

The problem can be supressed by adding an extra set of parentheses, but

I don't think that should be neccesary.

In the example posted below, this would work just fine:

if ( ( $a = 1 ) && $a > 0 ) {

Reproduce code:
---------------
$a = 0;
if ( $a = 1 && $a > 0 ) {
  echo 'ok';
}
else {
  echo 'wait, what?';
}

Expected result:
----------------
ok

Actual result:
--------------
wait, what?


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


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

Reply via email to