headers_list
返回已发送的 HTTP 响应头(或准备发送的)
headers_list() 函数返回要发送到浏览器的响应标头列表。
提示:如需确定标头是否已发送,请使用 headers_sent() 函数。
返回已发送的响应标头列表:
<?php
setcookie("TestCookie","SomeValue");
header("X-Sample-Test: foo");
header("Content-type: text/plain");
?>
<html>
<body>
<?php
var_dump(headers_list());
?>
</body>
</html>
上面代码的输出可能是:
array(4)
{
[0]=> string(23) "X-Powered-By: PHP/7.1.1"
[1]=> string(19) "Set-Cookie: TestCookie=SomeValue"
[2]=> string(18) "X-Sample-Test: foo"
[3]=> string(24) "Content-type: text/plain"
}
headers_list()