Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3422

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Issue HTTP redirect</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-request.html">http_request</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-send-content-disposition.html">http_send_content_disposition</a></div>
 <div class="up"><a href="ref.http.html">HTTP Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-redirect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_redirect</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">http_redirect</span> &mdash; <span class="dc-title">Issue HTTP redirect</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-redirect-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>http_redirect</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$url</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$params</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$session</code><span class="initializer"> = false</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$status</code><span class="initializer"> = 0</span></span>
  ]]]] )</div>

  <p class="para rdfs-comment">
   Redirect to the given url.
  </p>
  <p class="para">
   The supplied <em><code class="parameter">url</code></em> will be expanded with  <span class="function"><a href="function.http-build-url.html" class="function">http_build_url()</a></span>, the <em><code class="parameter">params</code></em> array will
   be treated with  <span class="function"><a href="function.http-build-str.html" class="function">http_build_str()</a></span> and the session identification will be appended
   if <em><code class="parameter">session</code></em> is true. The HTTP response code will be set according to <em><code class="parameter">status</code></em>.
   You can use one of the <a href="http.constants.html#http.constants.redirect" class="link">redirect constants</a> for convenience.
   Please see <a href="http://www.faqs.org/rfcs/rfc2616" class="link external">&raquo;&nbsp;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 class="para">
   To be RFC compliant, &quot;Redirecting to &lt;a&gt;URL&lt;/a&gt;.&quot; will be displayed,
   if the client doesn&#039;t redirect immediately, and the request method was another one than HEAD.
  </p>
  <p class="para">
   A log entry will be written to the redirect log, if the <a href="http.configuration.html" class="link">INI setting</a>
   <a href="" class="link">http.log.redirect</a> is set and the redirect attempt was successful.
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-redirect-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">url</code></em></span>
     <dd>

      <p class="para">
       the URL to redirect to
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">params</code></em></span>
     <dd>

      <p class="para">
       associative array of query parameters
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">session</code></em></span>
     <dd>

      <p class="para">
       whether to append session information
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">status</code></em></span>
     <dd>

      <p class="para">
       custom response status code
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.http-redirect-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>FALSE</code></strong> or <em class="emphasis">exits</em> on success with the specified redirection status code.
   See the <a href="http.configuration.html" class="link">INI setting</a>
<a href="" class="link">http.force_exit</a> for what &quot;exits&quot; means.
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-redirect-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4373">
    <p><strong>Example #1 A  <span class="function"><strong>http_redirect()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />http_redirect</span><span style="color: #007700">(</span><span style="color: #DD0000">"relpath"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"value"</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">HTTP_REDIRECT_PERM</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
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&amp;PHPSESSID=abc

Redirecting to &lt;a href=&quot;http://www.example.com/curdir/relpath?name=value&amp;PHPSESSID=abc&quot;&gt;http://www.example.com/curdir/relpath?name=value&amp;PHPSESSID=abc&lt;/a&gt;.
</pre></div>
    </div>
   </div>
  </p>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.http-redirect-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">the <a href="class.httpresponse.html" class="link">
<a href="class.httpresponse.html" class="classname">HttpResponse</a></a> class if you are using PHP 5.1.0
and above</li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-request.html">http_request</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-send-content-disposition.html">http_send_content_disposition</a></div>
 <div class="up"><a href="ref.http.html">HTTP Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>