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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

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: Mon Apr 29 18:01:30 2024 UTC