我想知道,如何在所有链接中使用“filemtime”?
示例: - 我获取的PHP文件是:http://mywebsite.org/getdate.php - 我想要获取日期的链接是:http://thegoodwebsite.net/i/banp.gif
提前感谢您的帮助!
答案 0 :(得分:1)
内置的http
包装器不支持stat
系列功能,例如filemtime
。所以:你不能。
HTTP协议定义了您可以使用的Last-Modified
标头字段。
使用CURL:
$curl = curl_init('http://thegoodwebsite.net/i/banp.gif');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_FILETIME, true);
if (false !== curl_exec($curl)) {
$time = curl_getinfo($curl, CURLINFO_FILETIME);
echo 'remote time of the retrieved document: ', $time;
}
curl_close($curl);
如果你得到-1,那可能是未知的。