<?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.header-register-callback.php',
    1 => 'header_register_callback',
    2 => 'Call a header function',
  ),
  'up' => 
  array (
    0 => 'ref.network.php',
    1 => 'Netzwerk-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.header.php',
    1 => 'header',
  ),
  'next' => 
  array (
    0 => 'function.header-remove.php',
    1 => 'header_remove',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/network/functions/header-register-callback.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.header-register-callback" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">header_register_callback</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">header_register_callback</span> &mdash; <span class="dc-title">Call a header function</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.header-register-callback-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>header_register_callback</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Registers a function that will be called when PHP starts sending output.
  </p>
  <p class="para">
   The <code class="parameter">callback</code> is executed just after PHP prepares all
   headers to be sent, and before any other output is sent, creating a window
   to manipulate the outgoing headers before being sent.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.header-register-callback-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">callback</code></dt>
    <dd>
     <p class="para">
      Function called just before the headers are sent. It gets no parameters
      and the return value is ignored.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.header-register-callback-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt bei Erfolg <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.header-register-callback-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="header-register-callback.example.basic">
   <p><strong>Beispiel #1 <span class="function"><strong>header_register_callback()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type: text/plain'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'X-Test: foo'</span><span style="color: #007700">);<br /><br />function </span><span style="color: #0000BB">foo</span><span style="color: #007700">() {<br /> foreach (</span><span style="color: #0000BB">headers_list</span><span style="color: #007700">() as </span><span style="color: #0000BB">$header</span><span style="color: #007700">) {<br />   if (</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$header</span><span style="color: #007700">, </span><span style="color: #DD0000">'X-Powered-By:'</span><span style="color: #007700">) !== </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />     </span><span style="color: #0000BB">header_remove</span><span style="color: #007700">(</span><span style="color: #DD0000">'X-Powered-By'</span><span style="color: #007700">);<br />   }<br />   </span><span style="color: #0000BB">header_remove</span><span style="color: #007700">(</span><span style="color: #DD0000">'X-Test'</span><span style="color: #007700">);<br /> }<br />}<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">header_register_callback</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"a"</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
eine ähnliche Ausgabe wie:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Content-Type: text/plain

a</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-function.header-register-callback-notes">
  <h3 class="title">Anmerkungen</h3>
  <p class="para">
   <span class="function"><strong>header_register_callback()</strong></span> is executed just as the
   headers are about to be sent out, so any output from this function can
   break output.
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Header sind nur dann zugänglich und werden nur dann gesendet,
    wenn die genutzte SAPI sie unterstützt.
   </p>
  </p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.header-register-callback-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <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>
   <li><span class="function"><a href="function.header-remove.php" class="function" rel="rdfs-seeAlso">header_remove()</a> - Remove previously set headers</span></li>
   <li><span class="function"><a href="function.header.php" class="function" rel="rdfs-seeAlso">header()</a> - Sendet einen HTTP-Header in Rohform</span></li>
  </ul>
 </div>


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