it could be useful if you using nginx instead of apache
if (!function_exists('getallheaders'))
{
function getallheaders()
{
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
getallheaders
(PHP 4, PHP 5)
getallheaders — 모든 HTTP 요청 헤더를 가져옵니다
설명
array getallheaders
( void
)
현재 요청에서 모든 HTTP 헤더를 가져옵니다.
이 함수는 apache_request_headers()의 별칭입니다. 이 함수의 작동에 관해서는 apache_request_headers()를 참고하십시오.
이 함수는 PHP를 아파치 모듈로 설치하였을 때만 지원합니다.
반환값
현재 요청에 존재하는 모든 HTTP 헤더의 연관 배열, 실패시엔 FALSE.
예제
Example #1 getallheaders() 예제
<?php
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}
?>
주의
Note: PHP 4.3.3부터 이 함수를 넷스케이프/iPlanet/SunONE 웹서버의 NSAPI 서버 모듈에서도 사용할 수 있습니다.
getallheaders
joyview at gmail dot com
06-Jul-2008 03:52
06-Jul-2008 03:52
lorro at lorro dot hu
19-Apr-2005 01:25
19-Apr-2005 01: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.
