PHPのget_headersはコンテキストを許可していないと思いますので、デフォルトのストリームコンテキストを変更してリクエストのHEADだけを取得する必要があります。これにより、ページ上の他のリクエストにいくつかの問題が発生します。私はデフォルトのストリームのコンテキストをリセットする方法を見つけることができないようです。誰もがこのための修正を知っていPHP:get_headersは一時的なstream_contextを設定します
$default = stream_context_get_default(); //Get default stream context so we can reset it
stream_context_set_default(//Only fetch the HEAD
array(
'http' => array(
'method' => 'HEAD'
)
)
);
$headers = get_headers($url, 1); //Url can be whatever you want it to be
//var_dump($headers);
var_dump($default);
stream_context_set_default($default); //This doesn't work as it expects an array and not a resource pointer
:私のような何かをしようとしていますか?
私はそれがCurlを使うことが示唆されていることを知っていますが、私はむしろこれについてはないでしょう。ありがとう!
get_headers不一致:http://stackoverflow.com/questions/12781795/get-headers-inconsistency – Baba