<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.parse-str.php',
    1 => 'parse_str',
    2 => 'Parse a string as a URL query string',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.ord.php',
    1 => 'ord',
  ),
  'next' => 
  array (
    0 => 'function.print.php',
    1 => 'print',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/parse-str.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.parse-str" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">parse_str</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">parse_str</span> &mdash; <span class="dc-title">Parse a string as a URL query string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.parse-str-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>parse_str</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter reference">&$result</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="para rdfs-comment">
   Parses <code class="parameter">string</code> as if it were the query string
   passed via a URL and sets keys in the provided <code class="parameter">result</code>
   array. If no <code class="parameter">result</code> is passed, values are instead
   set as variables in the current scope.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.parse-str-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The input string.
      </p>
     </dd>
    
    
     <dt><code class="parameter">result</code></dt>
     <dd>
      <p class="para">
       A variable passed by reference, which will be set to an array
       containing the key-value pairs extracted from <code class="parameter">string</code>.
       If the <code class="parameter">result</code> parameter is not passed,
       a separate variable is set in the local scope for each key.
      </p>

      <div class="warning"><strong class="warning">Увага</strong>
       <p class="para">
        Using this function without the <code class="parameter">result</code> parameter is highly
        <em>DISCOURAGED</em> and <em>DEPRECATED</em> as of PHP 7.2.
        As of PHP 8.0.0, the <code class="parameter">result</code> parameter is <em>mandatory</em>.
       </p>
      </div>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.parse-str-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Не повертає значень.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.parse-str-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">result</code> is no longer optional.
      </td>
     </tr>

      <tr>
       <td>7.2.0</td>
       <td>
        Usage of <span class="function"><strong>parse_str()</strong></span> without a second parameter
        now emits an <strong><code><a href="errorfunc.constants.php#constant.e-deprecated">E_DEPRECATED</a></code></strong> notice.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.parse-str-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Using <span class="function"><strong>parse_str()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"first=value&amp;arr[]=foo+bar&amp;arr[]=baz"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Recommended<br /></span><span style="color: #0000BB">parse_str</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">$output</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$output</span><span style="color: #007700">[</span><span style="color: #DD0000">'first'</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;  </span><span style="color: #FF8000">// value<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$output</span><span style="color: #007700">[</span><span style="color: #DD0000">'arr'</span><span style="color: #007700">][</span><span style="color: #0000BB">0</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// foo bar<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$output</span><span style="color: #007700">[</span><span style="color: #DD0000">'arr'</span><span style="color: #007700">][</span><span style="color: #0000BB">1</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// baz<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   Any spaces and dots in parameter names are converted to underscores
   when creating array keys or local variables.
   This is because variable names in PHP are not allowed to contain spaces
   or dots, but applies even when using this function with the recommended
   <code class="parameter">result</code> parameter.   
   <div class="example" id="example-2">
    <p><strong>Приклад #2 <span class="function"><strong>parse_str()</strong></span> name mangling</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />parse_str</span><span style="color: #007700">(</span><span style="color: #DD0000">"My Value=Something"</span><span style="color: #007700">, </span><span style="color: #0000BB">$output</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$output</span><span style="color: #007700">[</span><span style="color: #DD0000">'My_Value'</span><span style="color: #007700">]; </span><span style="color: #FF8000">// Something<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p> 
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.parse-str-notes">
  <h3 class="title">Примітки</h3>

  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    <span class="function"><strong>parse_str()</strong></span> is affected by the <a href="info.configuration.php#ini.max-input-vars" class="link">max_input_vars</a>
    directive. Exceeding this limit triggers an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>,
    and any variables beyond the limit are not added to the result array.
    The default is 1000; adjust <a href="info.configuration.php#ini.max-input-vars" class="link">max_input_vars</a> as needed.
   </p>
  </p></blockquote>

  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    All values populated in the <code class="parameter">result</code> array
    (or variables created if second parameter is not set)
    are already URL-decoded using the same rules as <span class="function"><a href="function.urldecode.php" class="function">urldecode()</a></span>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    To get the query string of the current request, you may use the variable
    <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER['QUERY_STRING']</a></var>.
    Also, you may want to read the section on
    <a href="language.variables.external.php" class="link">variables from external
    sources</a>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.parse-str-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.parse-url.php" class="function" rel="rdfs-seeAlso">parse_url()</a> - Parse a URL and return its components</span></li>
    <li><span class="function"><a href="function.pathinfo.php" class="function" rel="rdfs-seeAlso">pathinfo()</a> - Returns information about a file path</span></li>
    <li><span class="function"><a href="function.http-build-query.php" class="function" rel="rdfs-seeAlso">http_build_query()</a> - Generate URL-encoded query string</span></li>
    <li><span class="function"><a href="function.urldecode.php" class="function" rel="rdfs-seeAlso">urldecode()</a> - Розкодовує рядок, який закодовано для URL</span></li>
   </ul>
  </p>
 </div>


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