<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Parse a configuration string</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pathinfo.html">pathinfo</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.parse-ini-string" class="refentry"> <div class="refnamediv"> <h1 class="refname">parse_ini_string</h1> <p class="verinfo">(PHP 5 >= 5.3.0, PHP 7)</p><p class="refpurpose"><span class="refname">parse_ini_string</span> — <span class="dc-title">Parse a configuration string</span></p> </div> <div class="refsect1 description" id="refsect1-function.parse-ini-string-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>parse_ini_string</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$ini</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$process_sections</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$scanner_mode</code><span class="initializer"> = INI_SCANNER_NORMAL</span></span> ]] )</div> <p class="para rdfs-comment"> <span class="function"><strong>parse_ini_string()</strong></span> returns the settings in string <code class="parameter">ini</code> in an associative array. </p> <p class="para"> The structure of the ini string is the same as the <var class="filename">php.ini</var>'s. </p> </div> <div class="refsect1 parameters" id="refsect1-function.parse-ini-string-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter">ini</code></dt> <dd> <p class="para"> The contents of the ini file being parsed. </p> </dd> <dt> <code class="parameter">process_sections</code></dt> <dd> <p class="para"> By setting the <code class="parameter">process_sections</code> parameter to <strong><code>TRUE</code></strong>, you get a multidimensional array, with the section names and settings included. The default for <code class="parameter">process_sections</code> is <strong><code>FALSE</code></strong> </p> </dd> <dt> <code class="parameter">scanner_mode</code></dt> <dd> <p class="para"> Can either be <strong><code>INI_SCANNER_NORMAL</code></strong> (default) or <strong><code>INI_SCANNER_RAW</code></strong>. If <strong><code>INI_SCANNER_RAW</code></strong> is supplied, then option values will not be parsed. </p> <p class="para"> As of PHP 5.6.1 can also be specified as <strong><code>INI_SCANNER_TYPED</code></strong>. In this mode boolean, null and integer types are preserved when possible. String values <em>"true"</em>, <em>"on"</em> and <em>"yes"</em> are converted to <strong><code>TRUE</code></strong>. <em>"false"</em>, <em>"off"</em>, <em>"no"</em> and <em>"none"</em> are considered <strong><code>FALSE</code></strong>. <em>"null"</em> is converted to <strong><code>NULL</code></strong> in typed mode. Also, all numeric strings are converted to integer type if it is possible. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.parse-ini-string-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The settings are returned as an associative <span class="type"><a href="language.types.array.html" class="type array">array</a></span> on success, and <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 notes" id="refsect1-function.parse-ini-string-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"> There are reserved words which must not be used as keys for ini files. These include: <em>null</em>, <em>yes</em>, <em>no</em>, <em>true</em>, <em>false</em>, <em>on</em>, <em>off</em>, <em>none</em>. Values <em>null</em>, <em>off</em>, <em>no</em> and <em>false</em> result in <em>""</em>, and values <em>on</em>, <em>yes</em> and <em>true</em> result in <em>"1"</em>, unless <strong><code>INI_SCANNER_TYPED</code></strong> mode is used. Characters <em>?{}|&~![()^"</em> must not be used anywhere in the key and have a special meaning in the value. </span> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.parse-ini-string-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.parse-ini-file.html" class="function" rel="rdfs-seeAlso">parse_ini_file()</a> - Parse a configuration file</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pathinfo.html">pathinfo</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>