#19008 [Opn->Bgs]: == is wrong
| From: | rasmus@php.net | Date: | Wed, 21 Aug 2002 01:32:18 +0000 |
| Subject: | #19008 [Opn->Bgs]: == is wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-17383@lists.php.net to get a copy of this message | ||
ID: 19008
Updated by: rasmus@php.net
Reported By: six@t0x.net
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: linux 2.4.18
PHP Version: 4.2.2
New Comment:
Which is why you should use === if you want to compare different types
like that. You are comparing an integer to a string, so PHP has to one
to the other. In this case it converted "*" to an integer which ends
up being 0 and 0==0 so that is the result you get. Do your own
conversion first to force it to convert the right one, or use === to
compare both type and value.
Previous Comments:
------------------------------------------------------------------------
[2002-08-20 21:17:07] six@t0x.net
What do you think of the result of the little script below ??
shouldn't == return false on this one ?
------------------------------------
t0x:~# php -v
4.2.2
t0x:~# php
<?
$a=0;
if ($a=="*") echo "argh\n";
?>
argh
t0x:~#
-------------------------------------
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19008&edit=1