getallheaders
array getallheaders()
Gets the HTTP headers that the client sent.
Returns:
Associative array containing a list of HTTP headers, or FALSE on error
Description:
Call this function to retrieve an array of all HTTP headers sent by the client browser to the server. This function returns an associative array filled with the headers, in which each key is the name of the header, and each data element is the value associated with that name. If you have safe_mode enabled in PHP, the "authorization" header isn't included in the result set.
Header names are not case-sensitive. A client may send "User-Agent: foo" or "user-agent: foo", or use any other combination of upper- and lowercase for the header name. However, the name of the key in the associative array returned by this function will exactly match the case of the name sent by the client, so looking for the "User-Agent" key in the array will not return the expected value if the client used "user-agent" as the header name.
Warning:
In versions prior to 3.0.6, problems occurred when key/value pairs were empty.
Version:
Existing since version 3.0
Example:
Output the client's User-Agent HTTP header
$headers = getallheaders();
if ($headers) {
$useragent = $headers["User-Agent"];
print("You are using $useragent.<br />\n");
}
|