是否有接受 URL 并从标题中检索上次修改日期的基本 php 方法?
这似乎是 php 可以做的事情,但我不确定要检查哪个对象。
谢谢
试一试……使用cURL。
$c = curl_init('http://...');
curl_setopt($c, CURLOPT_HEADER, 1); // Include the header
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // Return the result instead of printing it
$result = curl_exec($c);
if (curl_errno($c))
die(curl_error($c));
// $result now contains the response, including the headers
if (preg_match('/Last-Modified:(.*?)/i', $result, $matches))
var_dump($matches[1]);
谢谢...我尝试稍微修改您的版本,这似乎对我有用:
$c = curl_init('http://...');
curl_setopt($c, CURLOPT_HEADER, 1); // Include the header
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FILETIME, 1);
curl_exec($c);
$result = curl_getinfo($c);
if (curl_errno($c))
die(curl_error($c));
echo date('G:i M jS \'y',(int)$result['filetime']);