note 41986 added to language.types.string
| From: | www dot feisar dot de at rn2 dot php dot net | Date: | Wed, 28 Apr 2004 11:49:00 +0000 |
| Subject: | note 41986 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68943@lists.php.net to get a copy of this message | ||
watch out when comparing strings that are numbers. this example:
<?php
$x1 = '111111111111111111';
$x2 = '111111111111111112';
echo ($x1 == $x2) ? "true\n" : "false\n";
?>
will output "true", although the strings are different. With large integer-strings, it
seems that PHP compares only the integer values, not the strings. Even strval() will not work here.
To be on the safe side, use:
$x1 === $x2
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41986
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41986&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41986&report=yes
Search -- http://master.php.net/manage/user-notes.php