|  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
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:
Solve the problem:
24 + 20 = ?
Subscribe to this entry?

 [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-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 25 14:01:23 2021 UTC