php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29306 parse_ini_file and octal values
Submitted: 2004-07-21 16:32 UTC Modified: 2007-08-20 14:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: wolf at exitec dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.8 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 + 26 = ?
Subscribe to this entry?

 
 [2004-07-21 16:32 UTC] wolf at exitec dot de
Description:
------------
the parse_ini_file doesn't work as in older php-versions:

the paragraph starting with 0... (for example 0815) wasn't handled correctly.

please create the following test.ini file

[01]
e=e
f=f
[02]
g=g
h=h
[1]
a=a
b=b
[2]
c=c
d=d
[0815]
bla=bla

Reproduce code:
---------------
print_r(parse_ini_file("test.ini",true));



Expected result:
----------------
Array
(
    [01] => Array
        (
            [e] => e
            [f] => f
        )

    [02] => Array
        (
            [g] => g
            [h] => h
        )

    [1] => Array
        (
            [a] => a
            [b] => b
        )

    [2] => Array
        (
            [c] => c
            [d] => d
        )

    [0815] => Array
        (
            [bla] => bla
        )

)

Actual result:
--------------
Array
(
    [1] => Array
        (
            [a] => a
            [b] => b
        )

    [2] => Array
        (
            [c] => c
            [d] => d
        )

    [0] => Array
        (
            [bla] => bla
        )

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-27 04:43 UTC] curt@php.net
Items starting with 0 are treated as an octal value, since 0815 is an invalid octal value it will return 0, the octal value of 01 is 1, thus your results.

I'm changing this a problem with the documentation.
 [2004-07-27 11:44 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Keys and section names consisting from numbers are evaluated as PHP integers thus numbers starting by 0 are evaluated as octals and numbers starting by 0x are evaluated as hexadecimals."

 [2007-08-02 14:26 UTC] philip@php.net
This was fixed here:

  http://bugs.php.net/bug.php?id=41445

And the expected result will show up as of 5.2.4.

Reopening this report, be sure to update to the new doc style and utilize the changelog.
 [2007-08-20 14:32 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Before PHP 5.2.4, keys and section names consisting from numbers are evaluated as PHP integers"

New doc style will be applied with other files in the section.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC