php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41814 String comparison changed
Submitted: 2007-06-26 18:46 UTC Modified: 2007-06-27 09:23 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thomas dot hebinck at digionline dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Linux
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: thomas dot hebinck at digionline dot de
New email:
PHP Version: OS:

 

 [2007-06-26 18:46 UTC] thomas dot hebinck at digionline dot de
Description:
------------
The behaviour of the comparison of strings containing integers changed from PHP 5.2.0 to 5.2.1.

Reproduce code:
---------------
echo (int)('0x100000000000000000'=='0x100000000000000001');

Expected result:
----------------
0 // this was the result in PHP <= 5.2.0

Actual result:
--------------
1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-27 08:23 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You are comparing two numeric strings.
http://www.php.net/manual/en/language.operators.comparison.php
 [2007-06-27 09:10 UTC] thomas dot hebinck at digionline dot de
The problem is, that the behaviour changed from 5.2.0. to 5.2.1. 
The two integers are not the same - they are just both out of range.
It seems that PHP 5.2.0 didn't convert strings with out of range integers to integer while comparing, but PHP 5.2.1 does.
 [2007-06-27 09:23 UTC] tony2001@php.net
The current behaviour is correct.

>The two integers are not the same
They are not integers in the first place, they are floats.
Remove the quotes and you'll get the very same result.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 10:01:30 2025 UTC