From:             bphelan at paycomonline dot com
Operating system: Windows XP
PHP version:      5.3.0RC1
PHP Bug Type:     Strings related
Bug description:  Strange String Comparison

Description:
------------
Whenever you compare strings of the format "1D-XXXX" where XXXX is any
number between 4950 and 5201, they will always return true. For example
"1D-5155" == "1D-5200" will return true.

We are running an old version of PHP (4.3.6) but I haven't found any
instance where this bug was encountered. If this error has already been
corrected, if someone could let me know which version it was fixed, I'd
appreciate it.

Reproduce code:
---------------
for($i = 4950; $i <= 5201; $i++){
        $compareInt = "1D-$i";
        
        if($compareInt == "1D-5155"){
                echo "$compareInt == 1D-5155<BR>";
        }
        else{
                echo "$compareInt != 1D-5155<BR>";
        }
}

Expected result:
----------------
I've generated a simple for loop that goes through all of the values in
the range. One would expect that only one instance would be correct, namely
the case where $compareInt is "1D-5155"

Actual result:
--------------
If you take a look at the code you will see the listing of which values
are considered equal and which are not. For some reason all strings within
the range of 4950 to 5201 are considered equal if they are compared against
each other. All other strings outside of the range appear to be compared as
expected.

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

Reply via email to