#43964 [Opn->Bgs]: Comparison of strings containing numbers results in an incorrect response.
| From: | felipe@php.net | Date: | Tue, 29 Jan 2008 10:09:08 +0000 |
| Subject: | #43964 [Opn->Bgs]: Comparison of strings containing numbers results in an incorrect response. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121717@lists.php.net to get a copy of this message | ||
ID: 43964
Updated by: felipe@php.net
Reported By: twinge at magma dot ca
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: openSuse 10.3
PHP Version: 5.2.5
New Comment:
This is expected, PHP converts numerical string to type integer/float.
var_dump((int) "12345678901234567890123456789012");
var_dump((int) "12345678901234567890123456789011");
int(2147483647)
int(2147483647)
Previous Comments:
------------------------------------------------------------------------
[2008-01-29 09:25:48] twinge at magma dot ca
Description:
------------
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:
---------------
<?PHP
$value1="12345678901234567890123456789012";
$value2="12345678901234567890123456789011";
if ($value1!=$value2){print"Not equal.<br>";}
if ($value1==$value2){print"Equal.<br>";}
var_dump($value1);
print "<br>";
var_dump($value2);
print "<br>";
?>
Expected result:
----------------
Not equal.
string(32) "12345678901234567890123456789012"
string(32) "12345678901234567890123456789011"
Actual result:
--------------
Equal.
string(32) "12345678901234567890123456789012"
string(32) "12345678901234567890123456789011"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43964&edit=1