ID:               46208
 Updated by:       [EMAIL PROTECTED]
 Reported By:      brennan at reverseproductions dot com
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: OSX
 PHP Version:      5.2.6
 New Comment:

Integers prefixed with 0 are octal numbers, so 05 is really 5.

011 == 9

It's working exactly as designed.


Previous Comments:
------------------------------------------------------------------------

[2008-10-02 03:01:26] brennan at reverseproductions dot com

The issue is that the PHP language parser does seem to allow for 
comparing integers with strings.  As an example evaluate 5 == "5".  
Because of this, I would expect the integers, when automatically 
converted to a string, to be converted in a way which leaves the
leading 
zeroes.  To reword: when PHP converts 05 to a string behind the scenes

to evaluate 05 == "05" it should leave the leading 0's.

Maybe this ticket would be better marked as enhancement?

------------------------------------------------------------------------

[2008-10-01 09:20:25] [EMAIL PROTECTED]

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'.

------------------------------------------------------------------------

[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

Reply via email to