ID: 26314
User updated by: matteo at beccati dot com
-Summary: Decimal numbers starting with 0 wrongly treated as
octals, even when invalid
Reported By: matteo at beccati dot com
-Status: Bogus
+Status: Open
Bug Type: Scripting Engine problem
Operating System: Debian GNU/Linux 3.0
PHP Version: 4.3.4
New Comment:
Fixed summary...
Previous Comments:
------------------------------------------------------------------------
[2003-11-19 06:39:40] [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
This is exactly as it should be. If you prefix the 0 on a non-octal
number, PHP still treats it as an octal number as is described in the
manual.
------------------------------------------------------------------------
[2003-11-19 06:37:32] matteo at beccati dot com
Description:
------------
According to the manual, integers can be specified in the octal
notation preceding the number with a zero. Some lines below I can see
this regexp:
octal : 0[0-7]+
What I don't understand is why an invalid octal number preceded by a 0
is treated as an octal, having a value of 0.
I know that you'll probably answer that it's a feature and not a bug,
but I think that this behaviour should be highlighted in the manual :)
Also checked on PHP 4.1.2, 4.3.0 and 4.3.3
Reproduce code:
---------------
<?php
var_dump(07); // Correct
var_dump(010); // Correct
var_dump(08); // Wrong, 8 is not an octal number
?>
Expected result:
----------------
int(7)
int(8)
int(8)
Actual result:
--------------
int(7)
int(8)
int(0)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26314&edit=1