From:             tim dot lokot at printsoft dot com
Operating system: Win2K Pro
PHP version:      4.3.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Comparison fails for int(0) == string

Description:
------------
For some reason I cannot compare the integer zero to a string and get a
valid response back.  There are two ways that I can see to fix it:



1. Use the === operator

2. Typecast the integer to a string



Both of the above solutions work, yet for some reason, the == comparison
operator doesn't.

Reproduce code:
---------------
<?php



        $item = 0;



        var_dump ($item);



        if ($item == 'rubbish')

                echo 'Equals';

        else

                echo 'Is not equal';



?>

Expected result:
----------------
int(0)

Is not equal

Actual result:
--------------
int(0)

Equals

-- 
Edit bug report at http://bugs.php.net/?id=27475&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27475&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27475&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27475&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27475&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27475&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27475&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27475&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27475&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27475&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27475&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27475&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27475&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27475&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27475&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27475&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27475&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27475&r=float

Reply via email to