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

 ID:                 62722
 Updated by:         ras...@php.net
 Reported by:        bo0rsh201 at gmail dot com
 Summary:            incorrect comparison result
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Variables related
 Operating System:   Win7
 PHP Version:        5.4.5
 Block user comment: N
 Private report:     N

 New Comment:

'1'==1
That is, (int)'1' == 1
So (int)'hello world' == 0
it is consistent
Weak typing means there will be type juggling when you compare different types.
Use === if you want to prevent type juggling.


Previous Comments:
------------------------------------------------------------------------
[2012-08-02 06:59:20] bo0rsh201 at gmail dot com

Description:
------------
comparision of integer 0 and any string always returns true
the problem is independent from operands order.

Test script:
---------------
<?php
// the following code returns true
var_dump(('hello world' == 0));
// the same thing
var_dump((0 == 'hello world'));


Expected result:
----------------
I think it has to return false, matching inequal variables



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



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

Reply via email to