<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >http_redirect</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="HTTP" HREF="ref.http.html"><LINK REL="PREVIOUS" TITLE="http_request_body_encode" HREF="function.http-request-body-encode.html"><LINK REL="NEXT" TITLE="http_send_content_disposition" HREF="function.http-send-content-disposition.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.http-request-body-encode.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.http-send-content-disposition.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.http-redirect" ></A >http_redirect</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN71560" ></A ><P > (PECL)</P >http_redirect -- Issue HTTP redirect</DIV ><DIV CLASS="refsect1" ><A NAME="AEN71563" ></A ><H2 >Descrição</H2 >void <B CLASS="methodname" >http_redirect</B > ( [string url [, array params [, bool session = FALSE [, int status]]]] )<BR ></BR ><P > Redirect to the given url. </P ><P > The supplied <CODE CLASS="parameter" >url</CODE > will be expanded with <A HREF="function.http-build-url.html" ><B CLASS="function" >http_build_url()</B ></A >, the <CODE CLASS="parameter" >params</CODE > array will be treated with <A HREF="function.http-build-str.html" ><B CLASS="function" >http_build_str()</B ></A > and the session identification will be appended if <CODE CLASS="parameter" >session</CODE > is true. The HTTP response code will be set according to <CODE CLASS="parameter" >status</CODE >. You can use one of the <A HREF="missing-stuff.html#http.constants.redirect" >redirect constants</A > for convenience. Please see <A HREF="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3" TARGET="_top" >RFC 2616</A > for which redirect response code to use in which situation. By default PHP will decide which response status fits best. </P ><P > To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed, if the client doesn't redirect immediately, and the request method was another one than HEAD. </P ><P > A log entry will be written to the redirect log, if the <A HREF="ref.http.html#http.configuration" >Definições INI</A > <A HREF="missing-stuff.html#http.configuration.log.redirect" >http.log.redirect</A > is set and the redirect attempt was successful. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN71594" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >url</CODE ></DT ><DD ><P > the URL to redirect to </P ></DD ><DT ><CODE CLASS="parameter" >params</CODE ></DT ><DD ><P > associative array of query parameters </P ></DD ><DT ><CODE CLASS="parameter" >session</CODE ></DT ><DD ><P > whether to append session information </P ></DD ><DT ><CODE CLASS="parameter" >status</CODE ></DT ><DD ><P > custom response status code </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN71618" ></A ><H2 >Valores de retornado</H2 ><P > Returns <TT CLASS="constant" ><B >FALSE</B ></TT > or <SPAN CLASS="emphasis" ><I CLASS="emphasis" >exits</I ></SPAN > on success with the specified redirection status code. See the <A HREF="ref.http.html#http.configuration" >Definições INI</A > <A HREF="missing-stuff.html#http.configuration.force_exit" >http.force_exit</A > for what "exits" means. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN71625" ></A ><H2 >Exemplos</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN71628" ></A ><P ><B >Exemplo 1. A <B CLASS="function" >http_redirect()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />http_redirect</font><font color="#007700">(</font><font color="#DD0000">"relpath"</font><font color="#007700">, array(</font><font color="#DD0000">"name" </font><font color="#007700">=> </font><font color="#DD0000">"value"</font><font color="#007700">), </font><font color="#0000BB">true</font><font color="#007700">, </font><font color="#0000BB">HTTP_REDIRECT_PERM</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >O exemplo acima irá imprimir:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >HTTP/1.1 301 Moved Permanently X-Powered-By: PHP/5.2.2 Content-Type: text/html Location: http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc Redirecting to <a href="http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc">http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc</a>.</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN71634" ></A ><H2 >Veja também</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD >the <A HREF="missing-stuff.html#http.HttpResponse" ><B CLASS="classname" >HttpResponse</B ></A > class if you are using PHP-5.1 and above</TD ></TR ></TBODY ></TABLE ><P ></P > </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.http-request-body-encode.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.http-send-content-disposition.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >http_request_body_encode</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.http.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >http_send_content_disposition</TD ></TR ></TABLE ></DIV ></BODY ></HTML >