如何通过链接使用 filemtime?

问题描述 投票:0回答:1

我想知道,如何使用带有链接的“filemtime”?

示例:

预先感谢您的帮助!

php date hyperlink filemtime
1个回答
2
投票

内置

http
包装器不支持
stat
系列功能,例如
filemtime
。所以:你不能。

HTTP 协议定义了一个您可以使用的

Last-Modified
标头字段。 使用卷曲:

$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,它可能是未知的。

© www.soinside.com 2019 - 2024. All rights reserved.