mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
148 lines
4.4 KiB
XML
148 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: b4989f5c1f052314ff2c36e9cc3d56b3a7a24e9b Maintainer: leonardolara Status: ready -->
|
|
<refentry xml:id="function.headers-sent" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>headers_sent</refname>
|
|
<refpurpose>Verifica se ou onde os cabeçalhos foram enviados</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>headers_sent</methodname>
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">filename</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter role="reference">line</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Verifica se ou onde os cabeçalhos foram enviados.
|
|
</para>
|
|
<para>
|
|
Não é possível adicionar mais linhas de cabeçalho usando a função <function>header</function>
|
|
uma vez que o bloco de cabeçalho já tiver sido enviado. Usando esta função,
|
|
é possível pelo menos evitar mensagens de erro relacionadas ao cabeçalho HTTP.
|
|
Outra opção é usar <link linkend="ref.outcontrol">Buffer de Saída</link>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Se os parâmetros opcionais <parameter>filename</parameter> e
|
|
<parameter>line</parameter> forem informados,
|
|
<function>headers_sent</function> colocará o nome do arquivo fonte PHP
|
|
e o número da linha onde a saída iniciou nas variáveis <parameter>filename</parameter>
|
|
e <parameter>line</parameter>, respectivamente.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Se a saída foi iniciada antes da execução do arquivo fonte PHP (por exemplo, devido a um erro de inicialização),
|
|
o parâmetro <parameter>filename</parameter> será definido como uma string vazia.
|
|
</para>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>line</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O número da linha onde a saída iniciou.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>headers_sent</function> retornará &false; se nenhum cabeçalho HTTP
|
|
ainda tiver sido enviado, ou &true; caso contrário.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplos de uso de <function>headers_sent</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// Se nenhum cabeçalho tiver sido enviado, envia um
|
|
if (!headers_sent()) {
|
|
header('Location: http://www.example.com/');
|
|
exit;
|
|
}
|
|
|
|
// Um exemplo usando os parâmetros opcionais de arquivo e linha
|
|
// Observe que $filename e $linenum são passados para uso posterior.
|
|
// Não devem ser atribuídos valores a eles antecipadamente.
|
|
if (!headers_sent($filename, $linenum)) {
|
|
header('Location: http://www.example.com/');
|
|
exit;
|
|
|
|
// Aqui é exibida uma mensagem de erro.
|
|
} else {
|
|
|
|
echo "Cabeçalhos já enviados no arquivo $filename na linha $linenum\n" .
|
|
"Não é possível redirecionar, favor clicar neste atalho: <a " .
|
|
"href=\"http://www.example.com\">link</a>\n";
|
|
exit;
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.network.header.sapi;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>ob_start</function></member>
|
|
<member><function>trigger_error</function></member>
|
|
<member><function>headers_list</function></member>
|
|
<member>
|
|
Função <function>header</function> para uma descrição mais detalhada sobre
|
|
os assuntos envolvidos.
|
|
</member>
|
|
</simplelist>
|
|
</para>
|
|
</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
|
|
-->
|