且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从PHP中获取当前请求的http标头

更新时间:2021-11-22 06:30:29

从某人写的文件中获取评论 ...

Taken from the documentation someone wrote a comment...

if (!function_exists('getallheaders')) 
{ 
    function getallheaders() 
    { 
       $headers = array (); 
       foreach ($_SERVER as $name => $value) 
       { 
           if (substr($name, 0, 5) == 'HTTP_') 
           { 
               $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
           } 
       } 
       return $headers; 
    } 
}