php - CURL 仅在文件被修改时获取文件

标签 php curl file-get-contents

我如何了解文件是否在使用 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/

相关文章:

php - 获取全局用户的本地时间并以本地时区格式显示给其他时区用户

php - 覆盖 FOS Message Bundle 的模板

php+mysql,使用 "join"时出现汉字乱码

bash - 使用 bash、cURL 和 GitHub API 从命令行 fork GitHub 存储库

php - Curl 拒绝清除缓存的 session /cookie

python - 在curl中使用python字符串输出

php - 将当前年份和月份与 sql 查询中输入的数据库年月进行比较

php - file_get_contents() "failed to open stream: Network is unreachable"有效链接错误

php - cron 作业不会打开 file_get_contents

regex - Powershell3:识别并显示ascii文件中的最后n行