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.apache-request-headers.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.apache.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.apache-request-headers.php',
   
1 => 'apache_request_headers',
  ),
 
'up' =>
  array (
   
0 => 'ref.apache.php',
   
1 => 'Apache Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.apache-note.php',
   
1 => 'apache_note',
  ),
 
'next' =>
  array (
   
0 => 'function.apache-reset-timeout.php',
   
1 => 'apache_reset_timeout',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.apache-request-headers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">apache_request_headers</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">apache_request_headers</span> &mdash; <span class="dc-title">Fetch all HTTP request headers</span></p>

 </div>

 <a name="function.apache-request-headers.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>apache_request_headers</b></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Fetches all HTTP request headers from the current request.
  </p>
  <p class="simpara">This function is only supported when PHP
is installed as an Apache module.</p>
 </div>


 <a name="function.apache-request-headers.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   An associative array of all the HTTP headers in the current request, or
   <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="function.apache-request-headers.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">4.3.3</td>
       <td align="left">
        <blockquote><p><b class="note">Note</b>: As of PHP 4.3.3 you can use this function with the
<a href="ref.nsapi.php" class="link">NSAPI server module</a> in Netscape/iPlanet/SunONE
webservers, too.<br /></p></blockquote>
       </td>
      </tr>

      <tr valign="middle">
       <td align="left">4.3.0</td>
       <td align="left">
        Prior to PHP 4.3.0, <b>apache_request_headers()</b> was
        called <a href="function.getallheaders.php" class="function">getallheaders()</a>.  After PHP 4.3.0,
        <a href="function.getallheaders.php" class="function">getallheaders()</a> is an alias for
        <b>apache_request_headers()</b>.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>

 
 <a name="function.apache-request-headers.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>apache_request_headers()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$headers&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">apache_request_headers</span><span style="color: #007700">();<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$headers&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$header&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$header</span><span style="color: #DD0000">:&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #DD0000">&nbsp;&lt;br&nbsp;/&gt;\n"</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
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0
Host: www.example.com
Connection: Keep-Alive
</pre></div>
    </div>
   </div><p>
  </p>
 </div>


 <a name="function.apache-request-headers.notes"></a><div class="refsect1 notes">
  <h3 class="title">Notes</h3>
  <blockquote><p><b class="note">Note</b>:
  
    You can also get at the value of the common <acronym title="Common Gateway Interface">CGI</acronym> variables by
    reading them from the environment, which works whether or not
    you are using PHP as an <span class="productname">Apache</span> module. Use
    <a href="function.phpinfo.php" class="function">phpinfo()</a> to see a list of all of the available
    <a href="language.variables.predefined.php" class="link">environment variables</a>.
   <br />
  </p></blockquote>
 </div>


 <a name="function.apache-request-headers.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.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