get_headers_curl格式为($ url,1)

时间:2012-07-17 14:06:07

标签: php

标准的get_headers函数有多种格式

get_headers($url);
get_headers($url,1);

我使用curl来设置请求的超时,所以这是我的函数

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,       3);

$r = curl_exec($ch);
$r = split("\n", $r);
return $r;
} 

我试过了

get_headers_curl($url,1)

没有结果

所以请告诉我如何制作第二种格式

get_headers($url,1)

最好的问候

1 个答案:

答案 0 :(得分:0)

尝试使用curl_getinfo() 功能