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

 ID:                 64376
 User updated by:    ludko2 at gmail dot com
 Reported by:        ludko2 at gmail dot com
 Summary:            Comparison does not return correct value
 Status:             Not a bug
 Type:               Bug
 Package:            *Programming Data Structures
 Operating System:   win7 64bit
 PHP Version:        5.4.12
 Block user comment: N
 Private report:     N

 New Comment:

I object.. I am not comparing the string to int!

I am comparing an array key (that may be "0") to a string!

If this is not a bug, than there is a bug, that array key is transformed to an 
int if it is a string!


Previous Comments:
------------------------------------------------------------------------
[2013-03-07 15:54:19] ras...@php.net

You are comparing a string to an int. Both sides are cast to int. 
(int)"b0123..." 
cast to an integer is 0. 0==0.
Use === to force a strict comparison, or explicitly cast your operands to your 
desired type.

------------------------------------------------------------------------
[2013-03-07 12:08:45] ludko2 at gmail dot com

Description:
------------
Comparison between string and zero and string returns true?!?

var_dump("b0180e6574921b8b8de3c40bfd046571"==0);

tested on 5.4.6 win 7 64bit

Test script:
---------------
$arr = array("0"=>"b");
var_dump($arr);//array(1) {  [0]=>  string(1) "b"}
foreach($arr as $k=>$v){
   var_dump($k == "c"); // returns true (FAIL)
}
var_dump("b"==0);//returns true (FAIL)

var_dump("a"==1); // returns false (OK)

Expected result:
----------------
var_dump("b"==0);// expecting false


Actual result:
--------------
var_dump("b"==0);// returning true



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



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

Reply via email to