Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 18850 программистов и 1632 робота. Сейчас ищут 1782 программиста ...
HTTP::head
Вернуться к: HTTP
HTTP::head
HTTP::head – sends a "HEAD" command
Synopsis
require_once 'HTTP.php';
array HTTP::head ( string $url )
Sends a "HEAD" HTTP command to a server and returns the headers in an associative array.
Example
HEAD request to example.com
<?php
require_once "PEAR.php";
require_once "HTTP.php";
$result = HTTP::head("http://example.com/");
if (PEAR::isError($result)) {
echo "Error: " . $result->getMessage();
} else {
echo "<pre>";
print_r($result);
echo "</pre>";
}
?>
The output of the print_r() call is shown below.
Parameter
-
string $url - a valid absolute URL
Return value
array - an array containing the header lines or a PEAR_Error.
Example output:
<?php
Array
(
[response_code] => 200
[response] => HTTP/1.1 200 OK
[Date] => Tue, 25 Nov 2003 22:08:57 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
)
?>
Throws
Error code | Error message | Reason | Solution |
---|---|---|---|
NULL | "HTTP::head Error $errstr ($erno)" | Connection to server failed | Check connectivity of your host and the given URL in $url |
Note
This function can be called statically.
Вернуться к: HTTP