PHP headers_list() Function
Example
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"
}
Definition and Usage
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.
Syntax
headers_list()
Technical Details
Return Value: | A numerically indexed array of headers on success |
---|---|
PHP Version: | 5.0+ |
❮ PHP Network Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.