Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 1445

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>headers_sent</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Network - Funções de Rede"
HREF="ref.network.html"><LINK
REL="PREVIOUS"
TITLE="headers_list"
HREF="function.headers-list.html"><LINK
REL="NEXT"
TITLE="inet_ntop"
HREF="function.inet-ntop.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.headers-list.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.inet-ntop.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.headers-sent"
></A
>headers_sent</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN144204"
></A
><P
>    (PHP 3 &#62;= 3.0.8, PHP 4, PHP 5)</P
>headers_sent&nbsp;--&nbsp;Checks if or where headers have been sent</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN144207"
></A
><H2
>Description</H2
>bool <B
CLASS="methodname"
>headers_sent</B
> ( [string &#38;file [, int &#38;line]] )<BR
></BR
><P
>&#13;     <B
CLASS="function"
>headers_sent()</B
> will return <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if no HTTP headers
     have already been sent or <TT
CLASS="constant"
><B
>TRUE</B
></TT
> otherwise. If the optional
     <CODE
CLASS="parameter"
>file</CODE
> and <CODE
CLASS="parameter"
>line</CODE
> parameters
     are set, <B
CLASS="function"
>headers_sent()</B
> will put the PHP source
     file name and line number where output started in the <CODE
CLASS="parameter"
>file</CODE
>
     and <CODE
CLASS="parameter"
>line</CODE
> variables.
    </P
><P
>&#13;     You can't add any more header lines using the <A
HREF="function.header.html"
><B
CLASS="function"
>header()</B
></A
> 
     function once the header block has already been sent. Using this function 
     you can at least prevent getting HTTP header related error messages.
     Another option is to use <A
HREF="ref.outcontrol.html"
>Output Buffering</A
>.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      The optional <CODE
CLASS="parameter"
>file</CODE
> and <CODE
CLASS="parameter"
>line</CODE
> 
      parameters were added in PHP 4.3.0.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN144235"
></A
><P
><B
>Exemplo 1. Examples using <B
CLASS="function"
>headers_sent()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">// If no headers are sent, send one<br /></font><font color="#007700">if (!</font><font color="#0000BB">headers_sent</font><font color="#007700">()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Location: http://www.example.com/'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br />&nbsp;&nbsp;<br /></font><font color="#FF8000">// An example using the optional file and line parameters, as of PHP 4.3.0<br />// Note that $filename and $linenum are passed in for later use.<br />// Do not assign them values beforehand.<br /></font><font color="#007700">if (!</font><font color="#0000BB">headers_sent</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">, </font><font color="#0000BB">$linenum</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">header</font><font color="#007700">(</font><font color="#DD0000">'Location: http://www.example.com/'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br /><br /></font><font color="#FF8000">// You would most likely trigger an error here.<br /></font><font color="#007700">} else {<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Headers already sent in $filename on line $linenum</font><font color="#007700">\n</font><font color="#DD0000">" </font><font color="#007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"Cannot redirect, for now please click this &lt;a " </font><font color="#007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"href=\"http://www.example.com\"&gt;link&lt;/a&gt; instead\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     See also <A
HREF="function.ob-start.html"
><B
CLASS="function"
>ob_start()</B
></A
>, <A
HREF="function.trigger-error.html"
><B
CLASS="function"
>trigger_error()</B
></A
>, 
     and <A
HREF="function.header.html"
><B
CLASS="function"
>header()</B
></A
> for a more detailed discussion of the 
     matters involved.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.headers-list.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.inet-ntop.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>headers_list</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.network.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>inet_ntop</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>