Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 6794

php-manual-zh-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
>http_redirect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.http-request-body-encode.html"
ACCESSKEY="P"
>上一页</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"
>下一页</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="AEN75765"
></A
><P
>    (PECL)</P
>http_redirect&nbsp;--&nbsp;Issue HTTP redirect</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN75768"
></A
><H2
>说明</H2
>void <B
CLASS="methodname"
>http_redirect</B
> ( [string url [, array params [, bool session = FALSE [, int status]]]] )<BR
></BR
><P
>&#13;   Redirect to the given url.
  </P
><P
>&#13;   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
>&#13;   To be RFC compliant, "Redirecting to &#60;a&#62;URL&#60;/a&#62;." will be displayed,
   if the client doesn't redirect immediately, and the request method was another one than HEAD.
  </P
><P
>&#13;   A log entry will be written to the redirect log, if the <A
HREF="ref.http.html#http.configuration"
>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="AEN75799"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>url</CODE
></DT
><DD
><P
>&#13;       the URL to redirect to
      </P
></DD
><DT
><CODE
CLASS="parameter"
>params</CODE
></DT
><DD
><P
>&#13;       associative array of query parameters
      </P
></DD
><DT
><CODE
CLASS="parameter"
>session</CODE
></DT
><DD
><P
>&#13;       whether to append session information
      </P
></DD
><DT
><CODE
CLASS="parameter"
>status</CODE
></DT
><DD
><P
>&#13;       custom response status code
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN75823"
></A
><H2
>返回值</H2
><P
>&#13;   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"
>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="AEN75830"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN75833"
></A
><P
><B
>例 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">&lt;?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">=&gt; </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">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</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&#38;PHPSESSID=abc

Redirecting to &#60;a href="http://www.example.com/curdir/relpath?name=value&#38;PHPSESSID=abc"&#62;http://www.example.com/curdir/relpath?name=value&#38;PHPSESSID=abc&#60;/a&#62;.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN75839"
></A
><H2
>参见</H2
><P
>&#13;   <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"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.http-send-content-disposition.html"
ACCESSKEY="N"
>下一页</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"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>http_send_content_disposition</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>