【问题标题】:How use filemtime with all link?如何将 filemtime 与所有链接一起使用?
【发布时间】:2016-04-05 15:23:08
【问题描述】:

我想知道,如何在所有链接中使用“filemtime”?

示例: - 我用于获取的 PHP 文件是:http://mywebsite.org/getdate.php - 我想获取日期的链接是:http://thegoodwebsite.net/i/banp.gif

提前感谢您的帮助!

【问题讨论】:

    标签: php date hyperlink filemtime


    【解决方案1】:

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

    【讨论】:

    • “HTTP 协议定义了一个您可以使用的 Last-Modified 标头字段。”。怎么用?
    • @Aymeric98,添加了一个例子
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 2022-01-25
    相关资源
    最近更新 更多