|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44575 parse_ini_file comment # line problems
Submitted: 2008-03-31 09:29 UTC Modified: 2009-08-07 14:59 UTC
From: letssurf at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.3CVS-2008-11-01 OS: *
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.
Block user comment
Status: Assign to:
Bug Type:
From: letssurf at gmail dot com
New email:
PHP Version: OS:


 [2008-03-31 09:29 UTC] letssurf at gmail dot com
Any lines with comments starting with a # cause ini parsing to stop.

Reproduce code:
-- File: config.ini --
; this is a comment
# this is a comment
name = value

# this a comment

-- File: test.php --
$ini = parse_ini_file('config.ini', true);

Expected result:
Array ( [section1] => Array ( [name] => value ) )

Actual result:
Array ( [section1] => Array ( ) )


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 09:33 UTC]
Just FYI: # is not a comment in ini files. ; is.
 [2008-04-02 09:44 UTC] letssurf at gmail dot com

Shouldn't the function either report a parse error or using them as comments.
 [2008-04-02 10:28 UTC]
Yes, that's why I didn't bogus this. Propably we could allow # as comment too, but I'd still reserve it for #if..#else..#endif style constructs. Marcus, what's the deal with that?
 [2008-10-17 11:40 UTC] konstantin at symbi dot org
the behaviour which stops parsing on '#' breaks compatibility with php 

at least it should be documented, and an error/warning raised, but i do 
not understand the reason of breaking BC.
 [2008-11-02 14:04 UTC]
This really should be solved before PHP 5.3.0 goes out. Might 
otherwise cause pretty hard to find secondary "bugs".
 [2008-11-02 23:39 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

open -> to be documented.

Comments starting with # has been re-enabled in 5.3, but they throw an E_DEPRECATED warning.

 [2009-08-07 14:59 UTC]
This is duplicate report of bug #47703 which now includes some explanations too. :)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 11:03:37 2021 UTC