php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43859 Wrong comparison
Submitted: 2008-01-15 20:27 UTC Modified: 2008-01-18 01:25 UTC
From: seocar at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Fedora Core
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: seocar at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-15 20:27 UTC] seocar at gmail dot com
Description:
------------
Wrong comparison between two strings.
(Yes, I know about strict comparison, but I want to know about this case)

Reproduce code:
---------------
if ("0000" == "0e01")
	echo "BUG";
else
	echo "OK";

Expected result:
----------------
OK

Actual result:
--------------
BUG

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-18 01:25 UTC] jani@php.net
RTFM: http://www.php.net/manual/en/language.operators.comparison.php

And there it says under the table:

"If you compare two numerical strings, they are compared as integers."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 22:00:01 2025 UTC