php获取header头信息

$ignore = array('host','accept','content-length','content-type');
$headers = array();
foreach($_SERVER as $key=>$value){
    if(substr($key, 0, 5)==='HTTP_') {
        $key = substr($key, 5);
        $key = str_replace('_', ' ', $key);
        $key = str_replace(' ', '-', $key);
        $key = strtolower($key);

        if (!in_array($key, $ignore)) {
            $headers[$key] = $value;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/oHeiZhiShi123/article/details/83029076