Php/func network headers list
来自菜鸟教程
PHP headers_list()函数
例
返回发送的响应头的列表:
<?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()函数返回要发送到浏览器的响应头的列表。
Tip: 要确定标题是否已发送,请使用 headers_sent()
功能。
句法
headers_list()
技术细节
| 返回值: | 成功的标头数字索引数组 |
| PHP版本: | 5.0+ |