php 获取全部 HTTP 请求头信息
getallheaders
—获取全部 HTTP 请求头信息
此函数是apache_request_headers()的别名。
如果你使用nginx而不是apache,它会很有用
//it could be useful if you using nginx instead of apache
<?php
if (!function_exists('getallheaders'))
{
function 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;
}
}
?>
参考链接:
https://www.php.net/manual/zh/function.getallheaders.php