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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
49 - 37 = ?
Subscribe to this entry?

 
 [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 Apr 24 15:01:30 2024 UTC