php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1097 (0 == "test") is true?
Submitted: 1999-01-26 15:58 UTC Modified: 1999-01-26 16:23 UTC
From: eric at ipass dot net Assigned:
Status: Closed Package: Other
PHP Version: 3.0.6 OS: Solaris 2.5.1
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: eric at ipass dot net
New email:
PHP Version: OS:

 

 [1999-01-26 15:58 UTC] eric at ipass dot net
It appears that there is a problem between comparing 0 and a string.

<?
  if (0 == "test")
    echo "True";
  else
    echo "False";
?>

will report that the test is true.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-01-26 16:23 UTC] rasmus
You are comparing an integer to a string here.  The inetger value of "test" is 0, hence the equality.  Try:
if( (string) 0 == "test")
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC