php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19008 == is wrong
Submitted: 2002-08-20 21:17 UTC Modified: 2002-08-20 21:32 UTC
From: six at t0x dot net Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.2.2 OS: linux 2.4.18
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: six at t0x dot net
New email:
PHP Version: OS:

 

 [2002-08-20 21:17 UTC] six at t0x dot 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:~#
-------------------------------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-20 21:32 UTC] rasmus@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC