From:             ensnnet at gmail dot com
Operating system: windows xp sp3
PHP version:      5.2.6
PHP Bug Type:     Unknown/Other Function
Bug description:  Bad result in an expression evaluation

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 bug report at http://bugs.php.net/?id=45410&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45410&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45410&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45410&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45410&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45410&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45410&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45410&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45410&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45410&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45410&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45410&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45410&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45410&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45410&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45410&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45410&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45410&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45410&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45410&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45410&r=mysqlcfg

Reply via email to