|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #786 Incorrect expression evaluation
Submitted: 1998-09-25 05:51 UTC Modified: 1998-09-25 10:07 UTC
From: torben at coastnet dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0 Latest CVS OS: Linux 2.0.33 Slackware
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.
Block user comment
Status: Assign to:
Bug Type:
From: torben at coastnet dot com
New email:
PHP Version: OS:


 [1998-09-25 05:51 UTC] torben at coastnet dot com
The following script prints "$foo == 'r'. This happens in both the module
and CGI versions. 

$foo = 0;

if ( $foo == 'r' ) {
   echo "$foo == 'r'\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-25 10:07 UTC] zeev
When one the arguments to a comparison operator is a number,
or a string that looks like a number, the comparison is
done numerically.  In this case, 'r' is converted to a 0
(like any other non-numeric string), and thus the comparison
evaluates to TRUE.

If you know you want a string comparison, you should use
strcmp() instead.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 13:01:26 2020 UTC