headers_list
返回已發送的HTTP 響應頭(或準備發送的)
headers_list()
函數返回要發送到瀏覽器的響應標頭列表。
提示:如需確定標頭是否已發送,請使用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 >
上面代碼的輸出可能是:
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 ( )