#26314 [Bgs->Opn]: Decimal numbers starting with 0 always treated as octals, even when invalid
| From: | matteo at beccati dot com | Date: | Wed, 19 Nov 2003 11:50:13 +0000 |
| Subject: | #26314 [Bgs->Opn]: Decimal numbers starting with 0 always treated as octals, even when invalid | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969356970@lists.php.net to get a copy of this message | ||
ID: 26314
User updated by: matteo at beccati dot com
Reported By: matteo at beccati dot com
-Status: Bogus
+Status: Open
-Bug Type: Scripting Engine problem
+Bug Type: Documentation problem
Operating System: Debian GNU/Linux 3.0
PHP Version: 4.3.4
New Comment:
[Changed category to "Documentation problem"]
OK, I understand...
Can I suggest adding a warning in the manual to let people know what
happens when the provided number is invalid? IMHO that isn't much clear
now.
P.S.
Sorry for reopening it by changing the summary... I didn't know you
already answered :)
Previous Comments:
------------------------------------------------------------------------
[2003-11-19 06:48:40] derick@php.net
Fixed status
------------------------------------------------------------------------
[2003-11-19 06:40:55] matteo at beccati dot com
Fixed summary...
------------------------------------------------------------------------
[2003-11-19 06:39:40] derick@php.net
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