#26314 [NEW]: Decimal numbers starting with 0 wrongly treated as octals, even when invalid
| From: | matteo at beccati dot com | Date: | Wed, 19 Nov 2003 11:37:32 +0000 |
| Subject: | #26314 [NEW]: Decimal numbers starting with 0 wrongly treated as octals, even when invalid | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-50687@lists.php.net to get a copy of this message | ||
From: matteo at beccati dot com
Operating system: Debian GNU/Linux 3.0
PHP version: 4.3.4
PHP Bug Type: Scripting Engine problem
Bug description: Decimal numbers starting with 0 wrongly treated as octals, even when invalid
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 bug report at http://bugs.php.net/?id=26314&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26314&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26314&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26314&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26314&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26314&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26314&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26314&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26314&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26314&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26314&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26314&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26314&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26314&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26314&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26314&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26314&r=float