Get the last modified date of a remote file

前端 未结 8 2130
难免孤独
难免孤独 2020-11-29 02:45

I would like to get the last modified date of a remote file by means of curl. Does anyone know how to do that?

8条回答
  •  被撕碎了的回忆
    2020-11-29 03:14

    Had to solve similiar issue, but for me download once a day was enough so I compared just the modify day of the local (downloaded) cache file. The remote file had no Last-Modified header.

    $xml = 'test.xml';
    if (is_file($xml) || date('d', filemtime($xml)) != date('d')) {
        $xml = file_get_contents(REMOTE_URL);
    }
    

提交回复
热议问题