downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.headers-list.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.headers-list.php',
   
1 => 'headers_list',
  ),
 
'up' =>
  array (
   
0 => 'ref.network.php',
   
1 => 'Network Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.header.php',
   
1 => 'header',
  ),
 
'next' =>
  array (
   
0 => 'function.headers-sent.php',
   
1 => 'headers_sent',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.headers-list" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">headers_list</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">headers_list</span> &mdash; <span class="dc-title">Returns a list of response headers sent (or ready to send)</span></p>

 </div>
 
 <a name="function.headers-list.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><b>headers_list</b></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   <b>headers_list()</b> will return a list of headers to be sent
   to the browser / client.  To determine whether or not these headers have
   been sent yet, use <a href="function.headers-sent.php" class="function">headers_sent()</a>.
  </p>
 </div>


 <a name="function.headers-list.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a numerically indexed array of headers.
  </p>
 </div>


 <a name="function.headers-list.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 Examples using <b>headers_list()</b></b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;setcookie()&nbsp;will&nbsp;add&nbsp;a&nbsp;response&nbsp;header&nbsp;on&nbsp;its&nbsp;own&nbsp;*/<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Define&nbsp;a&nbsp;custom&nbsp;response&nbsp;header<br />&nbsp;&nbsp;&nbsp;This&nbsp;will&nbsp;be&nbsp;ignored&nbsp;by&nbsp;most&nbsp;clients&nbsp;*/<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"X-Sample-Test:&nbsp;foo"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Specify&nbsp;plain&nbsp;text&nbsp;content&nbsp;in&nbsp;our&nbsp;response&nbsp;*/<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;text/plain'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;What&nbsp;headers&nbsp;are&nbsp;going&nbsp;to&nbsp;be&nbsp;sent?&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">headers_list</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  string(23) &quot;X-Powered-By: PHP/5.1.3&quot;
  [1]=&gt;
  string(19) &quot;Set-Cookie: foo=bar&quot;
  [2]=&gt;
  string(18) &quot;X-Sample-Test: foo&quot;
  [3]=&gt;
  string(24) &quot;Content-type: text/plain&quot;
}

</pre></div>
    </div>
   </div><p>
  </p>
 </div>


 <a name="function.headers-list.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.headers-sent.php" class="function" rel="rdfs-seeAlso">headers_sent()</a> - Checks if or where headers have been sent</li>
    <li class="member"><a href="function.header.php" class="function" rel="rdfs-seeAlso">header()</a> - Send a raw HTTP header</li>
    <li class="member"><a href="function.setcookie.php" class="function" rel="rdfs-seeAlso">setcookie()</a> - Send a cookie</li>
    <li class="member"><a href="function.apache-response-headers.php" class="function" rel="rdfs-seeAlso">apache_response_headers()</a> - Fetch all HTTP response headers</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites