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

 ID:               51515
 User updated by:  ianbara at imap dot cc
 Reported by:      ianbara at imap dot cc
 Summary:          Testing the equality of a string and an int can fails
 Status:           Bogus
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: Ubuntu Linux
 PHP Version:      5.3.2

 New Comment:

Consider the below code, which returns "EQUALS, NOT EQUALS". If not a
bug 

exactly, surely this is not optimal behavior for a language. 



<?php



$old_bad = "fca4ed9b761ca8ad209293248c2cdb56"; 

$old_good = "4ed9b761ca8ad209293248c2cdb56"; 

$new = 0;



if ($old_bad == $new) {

   echo "EQUALS, ";

 } else {

   echo "NOT EQUALS, ";

}



if ($old_good == $new) {

   echo "EQUALS\n";

 } else {

   echo "NOT EQUALS\n";

}



?>


Previous Comments:
------------------------------------------------------------------------
[2010-04-09 01:05:23] fel...@php.net

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



------------------------------------------------------------------------
[2010-04-08 23:22:52] ianbara at imap dot cc

Description:
------------
The attached code prints out EQUALS for me. It should not do this. ===
Does work 

correctly however.

Test script:
---------------
<?php



$old = "fca4ed9b761ca8ad209293248c2cdb56"; 

$new = 0;



if ($old == $new)

   echo "EQUALS";

else

   echo "NOT EQUALS"



?>

Expected result:
----------------
NOT EQUALS

Actual result:
--------------
EQUALS


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



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

Reply via email to