headers_list
Returns the sent HTTP response header (or ready to be sent)
headers_list()
function returns a list of response headers to be sent to the browser.
Tip: To determine whether the header has been sent, please use headers_sent()
function.
Returns the sent response header list:
<?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 above code might 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" }
headers_list ( )