Bug #44990 [Nab]: array('word')==array(0) -- true
| From: | nikic@php.net | Date: | Thu, 14 Feb 2013 17:16:56 +0000 |
| Subject: | Bug #44990 [Nab]: array('word')==array(0) -- true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176631@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44990&edit=1
ID: 44990
Updated by: nikic@php.net
Reported by: design at apostolstudio dot com
Summary: array('word')==array(0) -- true
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
@radamanf: He is comparing with == so all array elements are also compared with ==. And as in PHP
'word'==0 they are considered equal. Are you suggesting that when you compare arrays with
== the elements should be compared with ===? That makes no sense to me.
Previous Comments:
------------------------------------------------------------------------
[2013-02-14 17:14:35] radamanf at gmail dot com
Related To: Bug #39579
------------------------------------------------------------------------
[2013-02-14 16:59:12] radamanf at gmail dot com
Comparison === needed ONLY if, during type conversion, we got same values, so String compare to
Integer should be compared using Integer converted to string and check if they are equal.
So if String is '' and Int is 0
or '1' == 1
'2' == 2
.. etc. only in this cases === is necessary to tell VARIABLE TYPE difference.
It's so obvious, why I'm explaining all this to you ?! You should know this better than
me! Please fix this BUG
------------------------------------------------------------------------
[2008-05-14 02:58:01] design at apostolstudio dot com
Thanks for explanations.
------------------------------------------------------------------------
[2008-05-14 02:39:53] cellog@php.net
use ===
'word' is converted to an integer for the comparison, and thus 0 == 0.
try this code:
if(array('word')===array(0)) echo "ERROR";
------------------------------------------------------------------------
[2008-05-14 02:27:10] design at apostolstudio dot com
Description:
------------
array('word')==array(0) -- return true
Reproduce code:
---------------
if(array('word')==array(0)) echo "ERROR";
Actual result:
--------------
ERROR
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44990&edit=1