php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49539 {08} and {09} behave like {00}
Submitted: 2009-09-13 03:50 UTC Modified: 2009-09-14 03:30 UTC
From: info at daniel-marschall dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: info at daniel-marschall dot de
New email:
PHP Version: OS:

 

 [2009-09-13 03:50 UTC] info at daniel-marschall dot de
Description:
------------
I believe I found an error in PHP 5.2.0-8+etch15 (cli)

<?php

$quad = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

echo $quad{8}; // I
echo $quad{08}; // A <- ERROR

echo $quad{9}; // K
echo $quad{09}; // A <- ERROR

?>

The other values {00} to {07} are working as expected. Why doesn'T {08} and {09} work? They should behave like {8} and {9} since 08 == 8 and 09 == 9.


Reproduce code:
---------------
<?php

$quad = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

echo $quad{8}; // I
echo $quad{08}; // A <- ERROR

echo $quad{9}; // K
echo $quad{09}; // A <- ERROR

?>

Expected result:
----------------
Output: IIKK

Actual result:
--------------
Output: IAKA

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-13 03:51 UTC] info at daniel-marschall dot de
(I mean "IIJJ", of course.)
 [2009-09-13 04:00 UTC] rasmus@php.net
You have discovered octal numbers.  There is no 08 and 09 in octal.
 [2009-09-14 03:30 UTC] info at daniel-marschall dot de
I'm sorry. I didn't knew that a zero in front of a number makes difference.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 04:01:31 2024 UTC