我想從文件中獲取標頭。 但CURL返回值與get_headers不同。CURL get header返回與get_headers不同
不知道爲什麼。 這裏的結果:
與get_headers
Array
(
[0] => HTTP/1.0 200 OK
[1] => Content-Type: image/jpeg
[2] => Last-Modified: Wed, 14 Nov 2012 11:06:07 GMT
[3] => X-Cache-Status: HIT
[4] => Expires: Tue, 19 Jan 2038 03:14:07 GMT
[5] => Cache-Control: max-age=2592000
[6] => X-Cache: HIT
[7] => Content-Length: 120185
[8] => Connection: close
[9] => Date: Fri, 16 Nov 2012 08:01:15 GMT
[10] => Server: lighttpd/1.4.26
)
和捲曲沒有內容類型〜>這就是我想要什麼
Array
(
[0] => HTTP/1.1 200 OK
[1] => Content-Length: 120185
[2] => Connection: close
[3] => Date: Fri, 16 Nov 2012 08:01:42 GMT
[4] => Server: lighttpd/1.4.26
[5] =>
[6] =>
)
這裏是由捲曲功能我GET頭
function get_headers_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$r = curl_exec($ch);
$r = split("\n", $r);
return $r;
}
CURL與返回Content-Type如果我設置
curl_setopt($ch,CURLOPT_HTTPGET,true);
但它會返回文件內容(正文),如何獲得完全文件內容類型只有CURL和沒有文件內容?
什麼PHP的版本? – Baba
@Baba嗨,我的PHP版本是5.3 – TomSawyer
是否有可能提供用於測試的圖像URL?不能很好地複製你的問題,甚至PHP 5.3的 – Baba