array HTTP::head (
string $url
)
サーバーへ「HEAD」HTTPコマンドを送り、 連想の配列中でヘッダーを返します。
example.comへHEADリクエスト
<?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>";
}
?>
print_r()呼び出しの出力は 下記 の通りです。
string $url
- 有効な絶対URL
array
-
ヘッダー行を含む配列かPEAR_Errorを返します。
出力例:
<?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
)
?>
エラーコード | エラーメッセージ | 意味 | 解決策 |
---|---|---|---|
NULL |
"HTTP::head Error $errstr ($erno )"
|
サーバーへの接続に失敗しました。 |
あなたのホストと$url に与えたURLの接続を調べます。
|
This function can be called statically.