#47703 [Ana]: ini file syntax not well documented

From: Date: Fri, 07 Aug 2009 14:58:05 +0000
Subject: #47703 [Ana]: ini file syntax not well documented
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2618@lists.php.net to get a copy of this message
 ID:               47703
 Updated by:       jani@php.net
 Reported By:      ctoomey at yahoo-inc dot com
 Status:           Analyzed
 Bug Type:         Documentation problem
 Operating System: *
 PHP Version:      Irrelevant
 New Comment:

See also bug #44575


Previous Comments:
------------------------------------------------------------------------

[2009-08-07 14:56:35] 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.


------------------------------------------------------------------------

[2009-03-18 07:17:19] 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.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47703&edit=1



Thread (5 messages)

« previous php.doc.bugs (#2618) next »