Latest web development tutorials

PHP headers_list () function

PHP HTTP Reference Manual Complete PHP HTTP Reference Manual

Definition and Usage

headers_list () function returns sent (or to be sent) in response to a list of the head.

This function returns an array containing the header.

grammar

headers_list()


Tips and Notes

Tip: To determine whether the transmission header, use headers_sent () function.


Example 1

<?php
setcookie("TestCookie","SomeValue"');
header("X-Sample-Test: foo");
header('Content-type: text/plain');
?>

<html>
<body>

<?php
// What headers are to be sent?
var_dump(headers_list());
?>

</body>
</html>

The code above will output:

array(4)
{
[0]=> string(23) "X-Powered-By: PHP/5.1.1"
[1]=> string(19) "Set-Cookie: TestCookie=SomeValue"
[2]=> string(18) "X-Sample-Test: foo"
[3]=> string(24) "Content-type: text/plain"
}


PHP HTTP Reference Manual Complete PHP HTTP Reference Manual