1、PHP 自带函数 getallheaders()
此函数传回现行的请求的所有HTTP标头,传回值是一数组形态,只能在是apache环境下使用
foreach (getallheaders() as $name => $value) { echo "$name: $value\n"; }
2、自定义函数
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; }
上一篇: 如何才能有效降低网站的用户跳出率?
下一篇: 如何免费获得一个网站?自助建站怎么操作?
关键词: