您正在将$
header传递给
curl_getinfo()。应该是
$curl(卷曲手柄)。您可以
filetime通过将
CURLINFO_FILETIME作为第二个参数传递给来获得
curl_getinfo()。(通常
filetime是不可用,在这种情况下,它将报告为-1)。
但是,您的课程似乎很浪费,浪费了很多可能有用的信息。这是可以完成的另一种方法:
class URIInfo { public $info; public $header; private $url; public function __construct($url) { $this->url = $url; $this->setData(); } public function setData() { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $this->url); curl_setopt($curl, CURLOPT_FILETIME, true); curl_setopt($curl, CURLOPT_NOBODY, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); $this->header = curl_exec($curl); $this->info = curl_getinfo($curl); curl_close($curl); } public function getFiletime() { return $this->info['filetime']; } // Other functions can be added to retrieve other information.}$uri_info = new URIInfo('http://www.codinghorror.com/blog/');$filetime = $uri_info->getFiletime();if ($filetime != -1) { echo date('Y-m-d H:i:s', $filetime);} else { echo 'filetime not available';}是的,服务器上的负载将减轻,因为它仅返回HTTP标头(毕竟响应
HEAD请求)。多少打火机会有很大的不同。



