Adding that really neat parse_ini_file, with a complete example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@61972 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Gabor Hojtsy 2001-11-11 11:53:09 +00:00
parent 9daae4409f
commit 9bbfab707a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.86 $ -->
<!-- $Revision: 1.87 $ -->
<reference id="ref.filesystem">
<title>Filesystem functions</title>
<titleabbrev>Filesystem</titleabbrev>
@ -2173,6 +2173,110 @@ mkdir ("/path/to/my/dir", 0700);
</refsect1>
</refentry>
<refentry id="function.parse-ini-file">
<refnamediv>
<refname>parse_ini_file</refname>
<refpurpose>Parse a configuration file</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>array <function>parse_ini_file</function></funcdef>
<paramdef>string <parameter>filename</parameter></paramdef>
<paramdef>bool
<parameter>
<optional>process_sections</optional>
</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>parse_ini_file</function> loads in the
ini file specified in <parameter>filename</parameter>,
and returns the settings in it in an associative array.
By setting the last <parameter>process_sections</parameter>
parameter to &true;, you get a multidimensional array, with
the section names and settings included. The default
for <parameter>process_sections</parameter> is &false;
</para>
<note>
<para>
This function has nothing to do with the
<filename>php.ini</filename> file. It is already processed,
the time you run your script. This function can be used to
read in your own application's configuration files.
</para>
</note>
<para>
The structure of the ini file is similar to that of
the <filename>php.ini</filename>'s.
</para>
<para>
<example>
<title>Contents of sample.ini</title>
<programlisting>
; This is a sample configuration file
; Comments start with ';', as in php.ini
[first_section]
one = 1
five = 5
[second_section]
path = /usr/local/bin
</programlisting>
</example>
</para>
<para>
<example>
<title><function>parse_ini_file</function> example</title>
<programlisting>
<![CDATA[
<?php
// Parse without sections
$ini_array = parse_ini_file("sample.ini");
print_r($ini_array);
// Parse with sections
$ini_array = parse_ini_file("sample.ini", TRUE);
print_r($ini_array);
?>
]]>
</programlisting>
</example>
</para>
<para>
Would produce:
<informalexample>
<programlisting>
Array
(
[one] => 1
[five] => 5
[path] => /usr/local/bin
)
Array
(
[first_section] => Array
(
[one] => 1
[five] => 5
)
[second_section] => Array
(
[path] => /usr/local/bin
)
)
</programlisting>
</informalexample>
</para>
</refsect1>
</refentry>
<refentry id="function.pathinfo">
<refnamediv>
@ -2228,7 +2332,6 @@ html
</refsect1>
</refentry>
<refentry id="function.pclose">
<refnamediv>
<refname>pclose</refname>