Get_headers () is a PHP system-level function that returns an array containing the headers that the server responds to an HTTP request. Returns False if it fails and emits a e_warning-level error message that can be used to determine whether a remote file exists.
function definition
Array get_headers (string $url [, int $format = 0])
Parameters
URL Destination URL
Format if you set the optional format parameter to 1, Get_headers () parses the appropriate information and sets the key name of the array.
Example
<?php
$url = ' http://www.phpernote.com ';
Print_r (Get_headers ($url));
Print_r (Get_headers ($url, 1));
?>
The output of the above routine is similar to the following:
Array
(
[0] => http/1.1 OK
[1] => Date: Sat, May 12:28:13 GMT
[2] => server:apache/1.3.27 (Unix) (red-hat/linux)
; [3] => last-modified:wed, 2003 23:11:55 GMT
[4] => ETag: "3f80f-1b6-3e1c b03b "
[5] => accept-ranges:bytes
[6] => content-length:438
[7] => connection:close
[8] => content-type:text/html
Array
(
[0] => http/1.1 OK
[Date] => Sat, May 12:28:14 GMT
[Server] => apache/1.3.27 (Unix) (Red-hat/linux)
[Last-modified] => Wed, 2003 23:11:55 GMT
[ETag] => "3f80f-1b6-3e1cb03b"
[Accept-ranges] => bytes
[Content-length] => 438
[Connection] => Close
[Content-type] => text/html
)