<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'function.request-parse-body.php',
    1 => 'request_parse_body',
    2 => 'Read and parse the request body and return the result',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Ağ İşlevleri',
  ),
  'prev' => 
  array (
    0 => 'function.pfsockopen.php',
    1 => 'pfsockopen',
  ),
  'next' => 
  array (
    0 => 'function.setcookie.php',
    1 => 'setcookie',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/network/functions/request-parse-body.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.request-parse-body" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">request_parse_body</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.4.0)</p><p class="refpurpose"><span class="refname">request_parse_body</span> &mdash; <span class="dc-title">Read and parse the request body and return the result</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.request-parse-body-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>request_parse_body</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="simpara">
   This function reads the request body and parses it according to the
   <code class="literal">Content-Type</code> header. Currently, two content types are
   supported:
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <span class="simpara">
     <code class="literal">application/x-www-form-urlencoded</code>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     <code class="literal">multipart/form-data</code>
    </span>
   </li>
  </ul>
  <p class="simpara">
   This function is used primarily to parse
   <code class="literal">multipart/form-data</code> requests with HTTP verbs other than
   <code class="literal">POST</code> which do not automatically populate the
   <var class="varname"><a href="reserved.variables.post.php" class="classname">$_POST</a></var> and <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var> superglobals.
  </p>

  <div class="caution"><strong class="caution">Dikkat</strong>
   <p class="simpara">
    The request body can only be consumed once.
    <span class="function"><strong>request_parse_body()</strong></span> consumes the request body without
    buffering it to the <code class="literal">php://input</code> stream.
    Conversely, if the body has already been read (e.g. via
    <code class="literal">php://input</code>), <span class="function"><strong>request_parse_body()</strong></span>
    will return empty data.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.request-parse-body-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <span class="simpara">
      The <code class="parameter">options</code> parameter accepts an associative array
      to override the following global <var class="filename">php.ini</var> settings for parsing of the
      request body.
     </span>
     <ul class="itemizedlist">
      <li class="listitem"><span class="simpara"><code class="literal">max_file_uploads</code></span></li>
      <li class="listitem"><span class="simpara"><code class="literal">max_input_vars</code></span></li>
      <li class="listitem"><span class="simpara"><code class="literal">max_multipart_body_parts</code></span></li>
      <li class="listitem"><span class="simpara"><code class="literal">post_max_size</code></span></li>
      <li class="listitem"><span class="simpara"><code class="literal">upload_max_filesize</code></span></li>
     </ul>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.request-parse-body-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   <span class="function"><strong>request_parse_body()</strong></span> returns an array pair with the
   equivalent of <var class="varname"><a href="reserved.variables.post.php" class="classname">$_POST</a></var> at index <code class="literal">0</code> and
   <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var> at index <code class="literal">1</code>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.request-parse-body-errors">
  <h3 class="title">Hatalar/İstisnalar</h3>
  <p class="simpara">
   When the request body is invalid,
   according to the <code class="literal">Content-Type</code> header,
   a <span class="exceptionname"><strong class="exceptionname">RequestParseBodyException</strong></span> is thrown.
  </p>
  <p class="simpara">
   A <span class="exceptionname"><a href="class.valueerror.php" class="exceptionname">ValueError</a></span> is thrown when
   <code class="parameter">options</code> contains invalid keys,
   or invalid values for the corresponding key.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.request-parse-body-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="function.request-parse-body.example.basic">
   <p><strong>Örnek 1 <span class="function"><strong>request_parse_body()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Parse request and store result in the $_POST and $_FILES superglobals.<br /></span><span style="color: #007700">[</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">, </span><span style="color: #0000BB">$_FILES</span><span style="color: #007700">] = </span><span style="color: #0000BB">request_parse_body</span><span style="color: #007700">();<br /></span><span style="color: #FF8000">// Echo the content of some transferred file<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$_FILES</span><span style="color: #007700">[</span><span style="color: #DD0000">'file_name'</span><span style="color: #007700">][</span><span style="color: #DD0000">'tmp_name'</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="function.request-parse-body.example.options">
   <p><strong>Örnek 2 <span class="function"><strong>request_parse_body()</strong></span> example with customized options</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// form.php<br /><br /></span><span style="color: #0000BB">assert_logged_in</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Only for this form, we allow a bigger upload size.<br /></span><span style="color: #007700">[</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">, </span><span style="color: #0000BB">$_FILES</span><span style="color: #007700">] = </span><span style="color: #0000BB">request_parse_body</span><span style="color: #007700">([<br />    </span><span style="color: #DD0000">'post_max_size' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'10M'</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">'upload_max_filesize' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'10M'</span><span style="color: #007700">,<br />]);<br /><br /></span><span style="color: #FF8000">// Do something with the uploaded files.<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>

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