<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.http-response-code.php',
    1 => 'http_response_code',
    2 => 'Get or Set the HTTP response code',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Netzwerk-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.http-get-last-response-headers.php',
    1 => 'http_get_last_response_headers',
  ),
  'next' => 
  array (
    0 => 'function.inet-ntop.php',
    1 => 'inet_ntop',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/network/functions/http-response-code.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 7, PHP 8)</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">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>http_response_code</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$response_code</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span></div>

  <p class="para rdfs-comment">
    Gets or sets the HTTP response status code.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.http-response-code-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">response_code</code></dt>
     <dd>
      <p class="para">
       The optional <code class="parameter">response_code</code> will set the response code.
      </p>
     </dd>
       
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.http-response-code-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   If <code class="parameter">response_code</code> is provided, then the previous
   status code will be returned. If <code class="parameter">response_code</code> is not
   provided, then the current status code will be returned. Both of these
   values will default to a <code class="literal">200</code> status code if used in a web
   server environment.
  </p>
  <p class="para">
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> will be returned if <code class="parameter">response_code</code> is not
   provided and it is not invoked in a web server environment (such as from a
   CLI application). <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> will be returned if
   <code class="parameter">response_code</code> is provided and it is not invoked in a
   web server environment (but only when no previous response status has been
   set).
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.http-response-code-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Using <span class="function"><strong>http_response_code()</strong></span> in a web server environment</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">// Get the current response code and set a new one<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">(</span><span style="color: #0000BB">404</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Get the new response 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">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int(200)
int(404)</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 Using <span class="function"><strong>http_response_code()</strong></span> in a CLI environment</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">// Get the current default response 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">());<br /><br /></span><span style="color: #FF8000">// Set a response 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">(</span><span style="color: #0000BB">201</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Get the new response 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">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">bool(false)
bool(true)
int(201)</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.http-response-code-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.header.php" class="function" rel="rdfs-seeAlso">header()</a> - Sendet einen HTTP-Header in Rohform</span></li>
    <li><span class="function"><a href="function.headers-list.php" class="function" rel="rdfs-seeAlso">headers_list()</a> - Liefert eine Liste der gesendeten (oder zum Senden vorbereiteten) Antwort-Header</span></li>
   </ul>
  </p>
 </div>
 


</div><?php manual_footer($setup); ?>