<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.parse-ini-string.php',
    1 => 'parse_ini_string',
    2 => 'Разбирает строку конфигурации',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Функции файловой системы',
  ),
  'prev' => 
  array (
    0 => 'function.parse-ini-file.php',
    1 => 'parse_ini_file',
  ),
  'next' => 
  array (
    0 => 'function.pathinfo.php',
    1 => 'pathinfo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/filesystem/functions/parse-ini-string.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.parse-ini-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">parse_ini_string</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">parse_ini_string</span> &mdash; <span class="dc-title">Разбирает строку конфигурации</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.parse-ini-string-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>parse_ini_string</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$ini_string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$process_sections</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$scanner_mode</code><span class="initializer"> = <strong><code><a href="filesystem.constants.php#constant.ini-scanner-normal">INI_SCANNER_NORMAL</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>parse_ini_string()</strong></span> возвращает настройки из строки
   <code class="parameter">ini_string</code> в виде ассоциативного массива.
  </p>
  <p class="para">
   Структура INI-строки такая же, как и в <var class="filename">php.ini</var>.
  </p>
  <div class="warning"><strong class="warning">Внимание</strong>
   <p class="simpara">
    Функция не должна использоваться с недоверенными входными данными,
    за исключением случаев, когда значение параметра <code class="parameter">scanner_mode</code>
    равно <strong><code><a href="filesystem.constants.php#constant.ini-scanner-raw">INI_SCANNER_RAW</a></code></strong>, поскольку обработанные данные
    могут содержать значения конфиденциальных констант, таких как константы,
    содержащие пароль базы данных.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.parse-ini-string-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">ini_string</code></dt>
     <dd>
      <p class="para">
       Содержимое разбираемого INI-файла.
      </p>
     </dd>
    
    
     <dt><code class="parameter">process_sections</code></dt>
     <dd>
      <p class="para">
       Установив в параметр <code class="parameter">process_sections</code>
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, можно получить многомерный массив, который включает
       названия секций и настроек. По умолчанию
       <code class="parameter">process_sections</code> равен <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
      </p>
     </dd>
    
    
     <dt><code class="parameter">scanner_mode</code></dt>
     <dd>
      <p class="para">
       Может принимать следующие значения: <strong><code><a href="filesystem.constants.php#constant.ini-scanner-normal">INI_SCANNER_NORMAL</a></code></strong>
       (по умолчанию) или <strong><code><a href="filesystem.constants.php#constant.ini-scanner-raw">INI_SCANNER_RAW</a></code></strong>. Если
       указано значение <strong><code><a href="filesystem.constants.php#constant.ini-scanner-raw">INI_SCANNER_RAW</a></code></strong>, то
       значения опций не будут обрабатываться.
      </p>
      <p class="para">
С PHP 5.6.1 также доступен режим <strong><code><a href="filesystem.constants.php#constant.ini-scanner-typed">INI_SCANNER_TYPED</a></code></strong>.
В этом режиме типы boolean, null и integer сохраняются, если возможно.
Строковые значения <code class="literal">&quot;true&quot;</code>, <code class="literal">&quot;on&quot;</code> и <code class="literal">&quot;yes&quot;</code>
преобразуются в <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, а значения <code class="literal">&quot;false&quot;</code>, <code class="literal">&quot;off&quot;</code>, <code class="literal">&quot;no&quot;</code>
и <code class="literal">&quot;none&quot;</code> — в <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. Значение <code class="literal">&quot;null&quot;</code> преобразовывается в <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
Кроме этого, числовые строки преобразуются в целые числа, если возможно.
</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.parse-ini-string-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   В случае успешного выполнения, настройки возвращаются в виде ассоциативного
   массива (<span class="type"><a href="language.types.array.php" class="type array">array</a></span>). В случае возникновения ошибки, возвращается <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.parse-ini-string-notes">
  <h3 class="title">Примечания</h3>
  <blockquote class="note"><p><strong class="note">Замечание</strong>: 
   <span class="simpara">
    Существует зарезервированные слова, которые нельзя использовать
    в качестве ключей в ini-файлах. Такими словами являются:
    <code class="literal">null</code>, <code class="literal">yes</code>,
    <code class="literal">no</code>, <code class="literal">true</code>, <code class="literal">false</code>,
    <code class="literal">on</code>, <code class="literal">off</code>, <code class="literal">none</code>.
    Значения <code class="literal">null</code>, <code class="literal">off</code>, <code class="literal">no</code> и
    <code class="literal">false</code> преобразуются в <code class="literal">&quot;&quot;</code>, а значения
    <code class="literal">on</code>, <code class="literal">yes</code> и <code class="literal">true</code> в <code class="literal">&quot;1&quot;</code>
    , но только если не используется режим
    <strong><code><a href="filesystem.constants.php#constant.ini-scanner-typed">INI_SCANNER_TYPED</a></code></strong> (доступен с PHP 5.6.1).
    Символы <code class="literal">?{}|&amp;~!()^&quot;</code> не должны использоваться
    в ключах и иметь какой-либо особый смысл в значениях.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.parse-ini-string-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.parse-ini-file.php" class="function" rel="rdfs-seeAlso">parse_ini_file()</a> - Обрабатывает конфигурационный файл</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>