PHP headers_list() function

Definition and Usage

The headers_list() function returns a list of sent (or pending to be sent) response headers.

This function returns an array containing headers.

Syntax

headers_list()

Hints and Comments

Hint:To determine if headers have been sent, use the headers_sent() function.

Example

<?php
setcookie("TestCookie","SomeValue");
header("X-Sample-Test: foo");
header('Content-type: text/plain');
?>
<html>
<body>
<?php
// Send which headers?
var_dump(headers_list());
?>
</body>
</html>