php.net |  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:
 [2008-03-31 09:29 UTC] letssurf at gmail dot com
Description:
------------
Any lines with comments starting with a # cause ini parsing to stop.

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

# this a comment

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


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

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

Shouldn't the function either report a parse error or using them as comments.
 [2008-04-02 10:28 UTC] jani@php.net
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 
5.2. 

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] jani@php.net
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] lbarnaud@php.net
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
http://snaps.php.net/.
 
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] jani@php.net
This is duplicate report of bug #47703 which now includes some explanations too. :)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 01:02:05 2014 UTC