PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #47703 ini file syntax not well documented
Submitted:18 Mar 7:17am UTC Modified: 7 Aug 2:58pm UTC
From:ctoomey at yahoo-inc dot com Assigned to:
Status:Analyzed Category:Documentation problem
Version:Irrelevant OS:*
Votes:6 Avg. Score:4.3 ± 0.7 Reproduced:6 of 6 (100.0%)
Same Version:6 (100.0%) Same OS:5 (83.3%)
View/Vote Add Comment Developer Edit Submission

Welcome! If you don't have a SVN 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.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: ctoomey at yahoo-inc dot com
New email:
Version: OS:
New/Additional Comment:

[18 Mar 7:17am UTC] ctoomey at yahoo-inc dot com
Description:
------------
The legal syntax for PHP ini files (both php.ini and those parsed by
parse_ini_file()) is not really fully described anywhere in the manual.
It'd be helpful to have that documented say on
http://www.php.net/manual/en/configuration.file.php, and then have the
parse_ini_file() and parse_ini_string() documentation pages link to that
syntax documentation.

There are bits and pieces of documentation, like in the comments of the
php.ini in Example 1 on the above page, and in the comments of the
latest php.ini in CVS.  Also, in the page for parse_ini_file(), it
documents the set of illegal words and characters for keys.  It also
says certain characters have "special meaning" in values, but doesn't
say what those meanings are / what they can be used for in values.

The lack of precise syntax documentation makes it hard to predict how
parse_ini_file() will actually treat a given ini file line (as an error,
as ok but with some odd value interpretation, or just silently ignore). 
The following examples illustrate; these are using 5.3.0-beta2 snapshot
on Windows.

			value of key "x" 
ini line		from parse_ini_file()
--------		---------------------
x = 'foo' ;blah		foo
	;; Single quotes are ok too?

# x = blah		N/A
	;; No keys parsed out for this line, and no syntax
	;; error reported -- is "#" a comment char.?

x = "foo" # test	foo# test
	;; Hmm, legal to have text after double quoted value
	;; and gets oddly appended to value.
	;; And no, guess "#" ISN'T a comment char.

foo bar car		N/A
	;; No keys parsed out for this line, and no syntax
	;; error reported.  What happened to it?

Reproduce code:
---------------
The above was done by varying the contents of test.ini and then running
the following command at the windows prompt:

% php -r "print_r(parse_ini_file('test.ini'));"

Expected result:
----------------
For most of the examples I expected syntax errors to be reported.  But
the larger issue is that without documentation of the legal syntax of
ini files, PHP users don't really know what's legal and what's not.

Actual result:
--------------
See above.

[7 Aug 2:56pm UTC] jani@php.net
In PHP 5.3 single quotes allow putting anything inside them, except
single quotes. In PHP 5.2 they have no meaning and are included in the
value.

# Is comment in PHP 5.3 but not in 5.2, and in 5.3 it's already
deprecated and using it causes a deprecated warning if error_reporting
is appropriate. And it's only comment when it's not used after =

Keys without values are just ignored. Only when there is = char, you get
it into the array.
[7 Aug 2:58pm UTC] jani@php.net
See also bug #44575

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC