當前位置: 首頁> 函數類別大全> headers_list

headers_list

返回已發送的HTTP 響應頭(或準備發送的)
名稱:headers_list
分類:網絡Network
所屬語言:php
一句話介紹:返回要發送到瀏覽器的響應標頭列表。

定義和用法

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 ( )
同類函數