1、PHP 自帶函數(shù) getallheaders()
此函數(shù)傳回現(xiàn)行的請求的所有HTTP標頭,傳回值是一數(shù)組形態(tài),只能在是apache環(huán)境下使用
foreach (getallheaders() as $name => $value) { echo "$name: $value\n"; }
function em_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; }
關鍵詞: