|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43964 Comparison of strings containing numbers results in an incorrect response.
Submitted: 2008-01-29 09:25 UTC Modified: 2008-01-29 10:09 UTC
From: twinge at magma dot ca Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.5 OS: openSuse 10.3
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: twinge at magma dot ca
New email:
PHP Version: OS:


 [2008-01-29 09:25 UTC] twinge at magma dot ca
If two strings containing numbers are compared using an if statement, only the first 16 bytes of the string are compared. Any bytes after the 16th byte are ignored in the comparison.

Reproduce code:


if ($value1!=$value2){print"Not equal.<br>";}
if ($value1==$value2){print"Equal.<br>";}

print "<br>";
print "<br>";


Expected result:
Not equal.
string(32) "12345678901234567890123456789012" 
string(32) "12345678901234567890123456789011" 

Actual result:
string(32) "12345678901234567890123456789012" 
string(32) "12345678901234567890123456789011" 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-29 10:09 UTC]
This is expected, PHP converts numerical string to type integer/float.

var_dump((int) "12345678901234567890123456789012");
var_dump((int) "12345678901234567890123456789011");

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 04:01:34 2024 UTC