본문 바로가기

[Function] $http_response_header

MintState 2009년 2월 25일 오전 11:34 조회 17761

[Function] $http_response_header

The $http_response_header array is similar to the get_headers() function. When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers.

PHP5 에서 get_headers()​와 비슷한 기능합니다. 주어진 URL에서 header 를 배열로 반환 합니다.
PHP4 에서 get_headers()를 대신 해서 쓸 수 있습니다.

예)

<?php
file_get_contents("http://google.co.kr"); 
var_dump($http_response_header);
?>

 

출력 :

array(19) {
  [0]=>
  string(30) "HTTP/1.0 301 Moved Permanently"
  [1]=>
  string(34) "Location: http://www.google.co.kr/"
  [2]=>
  string(38) "Content-Type: text/html; charset=UTF-8"
  [3]=>
  string(35) "Date: Wed, 25 Feb 2009 02:33:36 GMT"
  [4]=>
  string(38) "Expires: Fri, 27 Mar 2009 02:33:36 GMT"
  [5]=>
  string(38) "Cache-Control: public, max-age=2592000"
  [6]=>
  string(11) "Server: gws"
  [7]=>
  string(19) "Content-Length: 221"
  [8]=>
  string(17) "Connection: Close"
  [9]=>
  string(15) "HTTP/1.0 200 OK"
  [10]=>
  string(35) "Date: Wed, 25 Feb 2009 02:33:39 GMT"
  [11]=>
  string(16) "Pragma: no-cache"
  [12]=>
  string(38) "Expires: Fri, 01 Jan 1990 00:00:00 GMT"
  [13]=>
  string(50) "Cache-Control: no-cache, no-store, must-revalidate"
  [14]=>
  string(39) "Content-Type: text/html; charset=EUC-KR"
  [15]=>
  string(89) "Set-Cookie: IGTP=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=www.google.co.kr"
  [16]=>
  string(157) "Set-Cookie: PREF=ID=f91f35dde9284d31:NW=1:TM=1235529219:LM=1235529219:S=SPZzoz0uILEOZgpW; expires=Fri, 25-Feb-2011 02:33:39 GMT; path=/; domain=.google.co.kr"
  [17]=>
  string(12) "Server: igfe"
  [18]=>
  string(17) "Connection: Close"
}

예)

<?php
file_get_contents("http://img0.gmodules.com/ig/f/oKstlUEg20s/intl/ALL_kr/logo.gif"); 
var_dump($http_response_header); 
?>

출력 :

array(9) {
  [0]=>
  string(15) "HTTP/1.0 200 OK"
  [1]=>
  string(23) "Content-Type: image/gif"
  [2]=>
  string(44) "Last-Modified: Wed, 11 Feb 2009 04:09:06 GMT"
  [3]=>
  string(35) "Date: Wed, 25 Feb 2009 02:35:56 GMT"
  [4]=>
  string(38) "Expires: Thu, 25 Feb 2010 02:35:56 GMT"
  [5]=>
  string(39) "Cache-Control: public, max-age=31536000"
  [6]=>
  string(12) "Server: igfe"
  [7]=>
  string(20) "Content-Length: 8529"
  [8]=>
  string(17) "Connection: Close"
}
공유 X Facebook LINE QR 코드

댓글 0개

첫 댓글을 남겨보세요.