Return a list of response 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>
The output of the code above could be:
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"
}
The headers_list() function returns a list of response headers to be sent to the browser.
Tip: To determine whether or not the headers have been sent yet, use the headers_sent() function.
headers_list()
Return Value: | A numerically indexed array of headers on success |
---|---|
PHP Version: | 5.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!