Network headers_list

(PHP 5, PHP 7, PHP 8)

headers_list — 보낸(또는 보낼 준비가 된) 응답 헤더 목록을 반환합니다.


설명

headers_list(): array

headers_list()는 브라우저/클라이언트에 보낼 헤더 목록을 반환합니다. 이러한 헤더가 아직 전송되었는지 여부를 확인하려면 headers_sent()를 사용하십시오.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

숫자로 인덱스된 헤더 배열을 반환합니다.


Examples

예제 #1 headers_list() 사용 예제

                  
<?php

/* setcookie() will add a response header on its own */
setcookie('foo', 'bar');

/* Define a custom response header
   This will be ignored by most clients */
header("Example-Test: foo");

/* Specify plain text content in our response */
header('Content-Type: text/plain; charset=UTF-8');

/* What headers are going to be sent? */
var_dump(headers_list());

?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

array(3) {
  [0]=>
  string(19) "Set-Cookie: foo=bar"
  [1]=>
  string(17) "Example-Test: foo"
  [2]=>
  string(39) "Content-Type: text/plain; charset=UTF-8"
}
                

메모

메모: 헤더를 지원하는 SAPI가 사용 중일 때만 헤더에 액세스하고 출력할 수 있습니다.


기타