CURL 仅在已修改的情况下获取文件

use*_*466 5 php curl file-get-contents

我如何了解文件是否被修改过以使用 CURL 打开流(然后我可以使用 file-get-contents 打开它)

谢谢

Mih*_*rga 5

检查CURLINFO_FILETIME

$ch = curl_init('http://www.mysite.com/index.php');
curl_setopt($ch, CURLOPT_FILETIME, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$exec = curl_exec($ch);

$fileTime = curl_getinfo($ch, CURLINFO_FILETIME);
if ($fileTime > -1) {
    echo date("Y-m-d H:i", $fileTime);
} 
Run Code Online (Sandbox Code Playgroud)