php nginx 获取header信息

nginx中可能没有getallheaders函数

因此编写新函数

function NginxGetAllHeaders(){//获取请求头
$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;
}
原文地址:https://www.cnblogs.com/ylqs/p/8117285.html