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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM