IT/php

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

조원태 2016. 12. 21. 18:28
반응형

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


설명 ¶

array headers_list ( void )

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


반환값 ¶

헤더로 수치 적으로 배열 된 배열을 반환합니다.


예제 ¶

<?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("X-Sample-Test: foo");


/* Specify plain text content in our response */

header('Content-type: text/plain');


/* What headers are going to be sent? */

var_dump(headers_list());


?>

위 예제의 출력:


array(4) {

  [0]=>

  string(23) "X-Powered-By: PHP/5.1.3"

  [1]=>

  string(19) "Set-Cookie: foo=bar"

  [2]=>

  string(18) "X-Sample-Test: foo"

  [3]=>

  string(24) "Content-type: text/plain"

}



반응형