1、PHP 自带函数 getallheaders() 目前 getallheaders() 只能用于 apache 中。如果想在 nginx 中也能使用,可以使用自定义函数。
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}function em_getallheaders()
{
$headers = [];
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
相关教程:PHP视频教程
以上就是如何用PHP接收http请求头信息的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于如何用PHP接收http请求头信息的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did62741