PHP 주요레퍼런스/URL 함수

get_headers

웹 개발자의 비상 2011. 8. 8. 17:48
array get_headers(array url [,int formatx])
클라이언트의 요청에 대한 응답으로 서버가 전송하는 헤더 정보를 배열로 반환한다.

클라이언트의 url 요청에 따라 서버가 클라이언트에게 전송하는 모든 헤더 정보를 배열에 담아 반환
format을 1로 지정하면 연관배열 형태로 반환한다.

php 5.1.3 지원된다.

예제

<?php
$url = 'http://www.example.com';

print_r(get_headers($url));

print_r(get_headers($url, 1));
/*
Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Sat, 29 May 2004 12:28:13 GMT
[2] => Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
[3] => Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
[4] => ETag: "3f80f-1b6-3e1cb03b"
[5] => Accept-Ranges: bytes
[6] => Content-Length: 438
[7] => Connection: close
[8] => Content-Type: text/html
)

Array
(
[0] => HTTP/1.1 200 OK
[Date] => Sat, 29 May 2004 12:28:14 GMT
[Server] => Apache/1.3.27 (Unix) (Red-Hat/Linux)
[Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT
[ETag] => "3f80f-1b6-3e1cb03b"
[Accept-Ranges] => bytes
[Content-Length] => 438
[Connection] => close
[Content-Type] => text/html
)
*/
?>



728x90

'PHP 주요레퍼런스 > URL 함수' 카테고리의 다른 글

http_build_query  (0) 2011.08.08
base64_decode  (0) 2011.08.08
base64_encode  (0) 2011.08.08
rawurldecode  (0) 2011.08.08
rawurlencode  (0) 2011.08.08