apache_request_headers()与$ _SERVER [英] apache_request_headers() versus $_SERVER
问题描述
据我所知,apache_request_headers()
提供的信息与$_SERVER
相同,但是键略有不同.为什么有人要使用apache_request_headers()
而不是仅仅从$_SERVER
获取此信息?我在Centos上使用Apache运行PHP 5.3.18.谢谢
As far as I can tell, apache_request_headers()
provides the same information as $_SERVER
, but with slightly different keys. Why should someone ever use apache_request_headers()
and not just get this information from $_SERVER
? I am operating PHP 5.3.18 with Apache on Centos. Thank you
编辑. $_SERVER
和apache_request_headers()
Jun 2 08:50:53 localhost httpd: HTTP_HOST: www.badobe.com
Jun 2 08:50:53 localhost httpd: Host: www.badobe.com
Jun 2 08:50:53 localhost httpd: HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
Jun 2 08:50:53 localhost httpd: User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT: */*
Jun 2 08:50:53 localhost httpd: Accept: */*
Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.5
Jun 2 08:50:53 localhost httpd: Accept-Language: en-US,en;q=0.5
Jun 2 08:50:53 localhost httpd: HTTP_ACCEPT_ENCODING: gzip, deflate
Jun 2 08:50:53 localhost httpd: Accept-Encoding: gzip, deflate
Jun 2 08:50:53 localhost httpd: HTTP_REFERER: http://www.badobe.com/demo/administrator/index.php?cid=3
Jun 2 08:50:53 localhost httpd: Referer: http://www.badobe.com/demo/administrator/index.php?cid=3
Jun 2 08:50:53 localhost httpd: HTTP_COOKIE: PHPSESSID=feg3ecd4rsefvd03mgg6qear21
Jun 2 08:50:53 localhost httpd: Cookie: PHPSESSID=feg3ecd4rsefvd03mgg6qear21
Jun 2 08:50:53 localhost httpd: HTTP_CONNECTION: keep-alive
Jun 2 08:50:53 localhost httpd: Connection: keep-alive
Jun 2 08:50:53 localhost httpd: HTTP_IF_MODIFIED_SINCE: Sun, 02 Jun 2013 15:48:42 GMT
Jun 2 08:50:53 localhost httpd: If-Modified-Since: Sun, 02 Jun 2013 15:48:42 GMT
Jun 2 08:50:53 localhost httpd: HTTP_CACHE_CONTROL: max-age=0
Jun 2 08:50:53 localhost httpd: Cache-Control: max-age=0
推荐答案
我猜该功能仅适用于Apache.但这只是一个疯狂的猜测
i would guess the function only works with Apache. but that is just a wild guess
此外,我猜该函数将返回所有标头,其中我认为$ _SERVER包含一组预定义的标头
furthermore i would guess the function returns ALL headers, where I think $_SERVER contains a predefined set of headers
这篇关于apache_request_headers()与$ _SERVER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!