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가 사용 중일 때만 헤더에 액세스하고 출력할 수 있습니다.
기타
- headers_sent() - 헤더가 전송되었는지 여부 또는 위치 확인
- header() - 원시 HTTP 헤더 보내기
- setcookie() - 쿠키 보내기
- apache_response_headers() - 모든 HTTP 응답 헤더 가져오기
- http_response_code() - HTTP 응답 코드 가져오기 또는 설정