search for in the  
<ebcdic2asciivirtual>
Last updated: Thu, 19 May 2005

getallheaders

(PHP 3, PHP 4, PHP 5)

getallheaders -- Fetch all HTTP request headers

Description

array getallheaders ( void )

Fetches all HTTP requests from the current request.

This function is an alias for apache_request_headers(). Please read the apache_request_headers() documentation for more information on how this function works.

This function is only supported when PHP is installed as an Apache module.

Return Values

An associative array of all the HTTP headers in the current request, or FALSE on failure.

ChangeLog

VersionDescription
4.3.0 Became an alias for apache_request_headers(). Essentially, it was renamed. This is because this function only works with Apache.

Notes

Note: As of PHP 4.3.3 you can use this function with the NSAPI server module in Netscape/iPlanet/SunONE webservers, too.



User Contributed Notes
getallheaders
lorro at lorro dot hu
19-Apr-2005 08:25
Beware that RFC2616 (HTTP/1.1) defines header fields as case-insensitive entities. Therefore, array keys of getallheaders() should be converted first to lower- or uppercase and processed such.
ZevS
17-Apr-2005 03:24
if PHP installed not as Apache-module:

<?php
function emu_getallheaders() {
   foreach(
$_SERVER as $h=>$v)
       if(
ereg('HTTP_(.+)',$h,$hp))
          
$headers[$hp[1]]=$v;
   return
$headers;
}
?>

I put this code to file "/var/www/include", and edit php.ini:
auto_prepend_file = "/var/www/include"
jukkaho at mail dot student dot oulu dot fi
17-Jan-2003 04:14
This function really is useful. Although $_SERVER['HTTP_*']-variables seem to include all request headers, they are really only the most generally needed - not all of them.

One example that needs this functionality is Digest Authentication (http://www.ietf.org/rfc/rfc2617.txt). When implementing it in PHP script, you can't read client's "Authorization"-header without this function.
linuxapps at yahoo dot com
22-Nov-2002 09:14
I think the previous poster is new to web development, so to keep the confusion down I recommend that other newbies read a tutorial on the HTTP protocol.

The poster meant well, but server variables have absolutely nothing to do with this function (nor the HTTP protocol). They aren't a part of the received browser header. getallheaders() will return the entire BROWSER header string to an array.

That's all it is supposed to do and as it was pointed out (by smclean) that this is a VERY USEFUL feature for certain applications. That's why I looked up the function in the first place!

So, yes, you must use the $_SERVER array to retrieve server variables. And to understand certain variables passed by the server read up on the CGI protocol.
kevin at frontierworld dot com
14-Aug-2000 08:58
You can read the HTTP username and password via the Authorization header by decoding its value from base 64 (if you're using the BASIC authorization scheme). For details about using DBM to maintain usernames and passwords, see http://www.web-hosting.com/dbm.html
jarl at diku dot dk
25-Mar-2000 05:15
All the environment variables can be found here:
http://www.php.net/manual/language.variables.predefined.php

<ebcdic2asciivirtual>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT