一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php filemtime定时生成文件代码

时间:2011-06-01 编辑:简简单单 来源:一聚教程网

filemtime() 函数返回文件内容上次的修改时间。

若成功,则时间以 Unix 时间戳的方式返回。若失败,则返回 false。

语法
filemtime(filename)

$path = "a.txt";
if( file_exists( $path ) ){
  
 $filetimes = filemtime($path);
 $cutime =time();
 $uptime = 900;//15分钟生成一次
 if ($cutime-$filetimes>$uptime)
 {
  
  $h = fopen( $path,'w+' );
  fwrite( $h,'到了更新的时间' );
  fclose( $h );
  
 }
 
}
else
{
  $h = fopen( $path,'w+' );
  fwrite( $h,'文件不存在' );
  fclose( $h );
}

热门栏目