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