php 獲取遠程文件修改日期

/**
 * 獲取遠程文件的最後修改日期
 * $file    完整路徑
 * $ver     最後修改時間(時間戳)
 */
function remote_file_ctime($file){
    //清除緩存並再次檢查文件
    clearstatcache();
    $headInf = get_headers($file,1);
    if(isset($headInf['Last-Modified'])){
        $ver = strtotime($headInf['Last-Modified']);
        return $ver;
    }
    //404 Not Found
    return false;
}
相關文章
相關標籤/搜索