我如何了解文件是否在使用 CURL 打开流之前被修改 (然后我可以用 file-get-contents 打开它)
谢谢
最佳答案
检查 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);
}
关于php - CURL 仅在文件被修改时获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12636373/