#46208 [Opn->Bgs]: Comparing integer to string loses leading 0's
| From: | tularis@php.net | Date: | Wed, 01 Oct 2008 09:20:26 +0000 |
| Subject: | #46208 [Opn->Bgs]: Comparing integer to string loses leading 0's | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129383@lists.php.net to get a copy of this message | ||
ID: 46208
Updated by: tularis@php.net
Reported By: brennan at reverseproductions dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: OSX
PHP Version: 5.2.6
New Comment:
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
05 is an integer, not a string. And as far as integers go, 5 === 05 ===
000000005. If you want it to be a string, declare it as a string: '05'.
Previous Comments:
------------------------------------------------------------------------
[2008-10-01 06:19:08] brennan at reverseproductions dot com
Description:
------------
When comparing an integer with a string any leading 0's in the integers
are ignored.
Reproduce code:
---------------
$day = "05";
echo "05 == 05: ";
if (!(strcmp(05, $day)))
echo "equal";
else
echo "not equal";
echo "<br>";
echo "07 == 05: ";
if (!(strcmp(07, $day)))
echo "equal";
else
echo "not equal";
Expected result:
----------------
05 == 05: equal
07 == 05: not equal
Actual result:
--------------
05 == 05: not equal
07 == 05: not equal
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46208&edit=1