Home > php教程 > php手册 > php filemtime定时生成文件代码

php filemtime定时生成文件代码

WBOY
Release: 2016-05-25 16:56:53
Original
817 people have browsed it

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 );
}
Copy after login

本文链接:

收藏随意^^请保留教程地址.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template