Apache 服务器可以通过如下获取:

<?php
$headers = Apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
?>

其他服务环境:

<?php
function parseRequestHeaders() {
$headers = array();
foreach($_SERVER as $key => $value) {
if (substr($key, 0, 5) <> 'HTTP_') {
continue;
}
$header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
$headers[$header] = $value;
}
return $headers;
}
?>

整理自:http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php

Related Posts: PHP-提取访问者headers :