ID:               45410
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ensnnet at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: windows xp sp3
 PHP Version:      5.2.6
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The assignment is executed before the "and" operator, see the
precedence table in the docs, http://php.net/operator


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

[2008-07-01 21:33:57] ensnnet at gmail dot com

Description:
------------
A simple logical expression is bad evaluated.  Next code show that.

Reproduce code:
---------------
<?php
$emma   = "A";
$lobera = 0;

echo "[ The right answer is: Flag is off ]<br><br>";
// This run bad:
$flag = $emma=="A" and $lobera!=0;
evaluate($flag);

// This run well (why?):
$flag = ($emma=="A" and $lobera!=0);
evaluate($flag);


// This run well too:
$flag = $lobera!=0 and $emma=="A";
evaluate($flag);

// ============================================================

function evaluate($flag)
{
        if($flag)
                echo "Flag is on<br>";
        else
                echo "Flag is off<br>";
}
?>


Expected result:
----------------
[ The right answer is: Flag is off ]

Flag is off
Flag is off
Flag is off

Actual result:
--------------
[ The right answer is: Flag is off ]

Flag is on   <--- This is bad
Flag is off
Flag is off


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


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

Reply via email to