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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Wed May 01 21:01:29 2024 UTC