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