Current Location: Home> Function Categories> headers_list

headers_list

Returns the sent HTTP response header (or ready to be sent)
Name:headers_list
Category:Network
Programming Language:php
One-line Description:Returns the list of response headers to be sent to the browser.

Definition and usage

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.

Example

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"
}

grammar

 headers_list ( )
Similar Functions
Popular Articles