From: bd at avatartechnology dot com
Operating system: Linux RedHat 7.3
PHP version: 4.3.8
PHP Bug Type: Performance problem
Bug description: 'and' produces erroneous results
Description:
------------
Ran into a situation where code that utilized the operator 'and' produced
erroneous results.
$free_shipping = true;
$add_fee = 'Y';
$free_shipping = $free_shipping and $add_fee == 'N';
This was producing the result where $free_shipping was always true.
Adding parenthesis makes no difference in result.
--------------
$free_shipping = true;
$residential_fee = 'Y';
$free_shipping = $free_shipping && $residential_fee == 'N';
This accurately produces the correct results.
--------------
According to the documentation on PHP website 'and' and '&&' should be
used interchangably with same results.
Reproduce code:
---------------
$free_shipping = true;
$residential_fee = 'Y';
$free_shipping = $free_shipping and $residential_fee == 'N';
printf("free = %d",$free_shipping);
Expected result:
----------------
free = 0
Actual result:
--------------
free = 1
--
Edit bug report at http://bugs.php.net/?id=29758&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29758&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29758&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29758&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29758&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29758&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29758&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29758&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29758&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29758&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29758&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29758&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29758&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29758&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29758&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29758&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29758&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29758&r=float