Sophie

Sophie

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

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>Get or Set the HTTP response code</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.headers-sent.html">headers_sent</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.inet-ntop.html">inet_ntop</a></div>
 <div class="up"><a href="ref.network.html">Network Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-response-code" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_response_code</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0)</p><p class="refpurpose"><span class="refname">http_response_code</span> &mdash; <span class="dc-title">Get or Set the HTTP response code</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.http-response-code-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>http_response_code</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$response_code</code></span>
  ] )</div>

  <p class="para rdfs-comment">
  If you pass no parameters then http_response_code will get the current status code.
  If you pass a parameter it will set the response code.
  </p>

 </div>


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

    <dt>

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

      <p class="para">
       The optional <em><code class="parameter">response_code</code></em> will set the response code.
      </p>
      <p class="para">
       <div class="informalexample">
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />http_response_code</span><span style="color: #007700">(</span><span style="color: #0000BB">404</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
        </div>

       </div>
      </p>
     </dd>

    </dt>
   
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.http-response-code-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The current response code. By default the return value is int(200).
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.http-response-code-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4488">
    <p><strong>Example #1 Examples using  <span class="function"><strong>http_response_code()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Get&nbsp;the&nbsp;current&nbsp;default&nbsp;response&nbsp;code<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">http_response_code</span><span style="color: #007700">());&nbsp;</span><span style="color: #FF8000">//&nbsp;int(200)<br /><br />//&nbsp;Set&nbsp;our&nbsp;response&nbsp;code<br /></span><span style="color: #0000BB">http_response_code</span><span style="color: #007700">(</span><span style="color: #0000BB">404</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Get&nbsp;our&nbsp;new&nbsp;response&nbsp;code<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">http_response_code</span><span style="color: #007700">());&nbsp;</span><span style="color: #FF8000">//&nbsp;int(404)<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>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.http-response-code-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.header.html" class="function" rel="rdfs-seeAlso">header()</a> - Send a raw HTTP header</span></li>
    <li class="member"> <span class="function"><a href="function.headers-list.html" class="function" rel="rdfs-seeAlso">headers_list()</a> - Returns a list of response headers sent (or ready to send)</span></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.headers-sent.html">headers_sent</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.inet-ntop.html">inet_ntop</a></div>
 <div class="up"><a href="ref.network.html">Network Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>