mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
149 lines
4.8 KiB
XML
149 lines
4.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?><!-- EN-Revision: 4bf789e981af0836c41daa16e57ef86c21497faa Maintainer: leonardolara Status: ready -->
|
|
<refentry xml:id="function.request-parse-body" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>request_parse_body</refname>
|
|
<refpurpose>Lê e analisa o corpor da requisição e retorna o resultado</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>request_parse_body</methodname>
|
|
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>options</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Esta função lê o corpo da requisição e analisa-o de acordo com o
|
|
cabeçalho <literal>Content-Type</literal>. Atualmente, dois tipos de conteúdo são
|
|
suportados:
|
|
</simpara>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<literal>application/x-www-form-urlencoded</literal>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<literal>multipart/form-data</literal>
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<simpara>
|
|
Esta função é usada primariamente para analisar
|
|
requisições <literal>multipart/form-data</literal> com verbos HTTP diferentes de
|
|
<literal>POST</literal> que não populam automaticamente as
|
|
superglobais <varname>$_POST</varname> e <varname>$_FILES</varname>.
|
|
</simpara>
|
|
|
|
<caution>
|
|
<simpara>
|
|
<function>request_parse_body</function> consome o corpo da requisição sem
|
|
fazer buffer para o fluxo <literal>php://input</literal>.
|
|
</simpara>
|
|
</caution>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
O parâmetro <parameter>options</parameter> aceita um array associativo
|
|
para substituir as seguintes configurações globais do &php.ini; para analisar o
|
|
corpo da requisição.
|
|
</simpara>
|
|
<itemizedlist>
|
|
<listitem><simpara><literal>max_file_uploads</literal></simpara></listitem>
|
|
<listitem><simpara><literal>max_input_vars</literal></simpara></listitem>
|
|
<listitem><simpara><literal>max_multipart_body_parts</literal></simpara></listitem>
|
|
<listitem><simpara><literal>post_max_size</literal></simpara></listitem>
|
|
<listitem><simpara><literal>upload_max_filesize</literal></simpara></listitem>
|
|
</itemizedlist>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<simpara>
|
|
<function>request_parse_body</function> retorna um array com o
|
|
equivalente de <varname>$_POST</varname> no índice <literal>0</literal> e o de
|
|
<varname>$_FILES</varname> no índice <literal>1</literal>.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<simpara>
|
|
Quando o corpo da requisição for inválido,
|
|
de acordo com o cabeçalho <literal>Content-Type</literal>,
|
|
uma exceção <exceptionname>RequestParseBodyException</exceptionname> é lançada.
|
|
</simpara>
|
|
<simpara>
|
|
Uma exceção <exceptionname>ValueError</exceptionname> é lançada quando
|
|
<parameter>options</parameter> contiver chaves inválidas ou
|
|
valores inválidos para a chave correspondente.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example xml:id="function.request-parse-body.example.basic">
|
|
<title>Exemplo de <function>request_parse_body</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Analisa o resultado e armazena-o nas superglobais $_POST e $_FILES.
|
|
[$_POST, $_FILES] = request_parse_body();
|
|
// Exibe o conteúdo de um arquivo transferido
|
|
echo file_get_contents($_FILES['file_name']['tmp_name']);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example xml:id="function.request-parse-body.example.options">
|
|
<title>Exemplo de <function>request_parse_body</function> com opções personalizadas</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// form.php
|
|
|
|
assert_logged_in();
|
|
|
|
// Apenas para este formulário, um tamanho maior de envio é permitido.
|
|
[$_POST, $_FILES] = request_parse_body([
|
|
'post_max_size' => '10M',
|
|
'upload_max_filesize' => '10M',
|
|
]);
|
|
|
|
// Faz algo com os arquivos enviados.
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|