加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php文件时间函数fileatime filemtime filectime区别实例讲解

发布时间:2020-05-25 02:13:59 所属栏目:PHP 来源:互联网
导读:php fileatime、filemtime、filectime三个函数都是用来获取文件时间的,但是三者之间是有区别的,fileatime用于取得文件的上次访问时间,filemtime函数用于取得文件上传修改时间,filectime用于取得文件的 inode 修改时间(文件创建时间),本文章向大家实例介

fileatime

fileatime返回文件上次被访问的时间, 或者在失败时返回 FALSE 。时间以 Unix 时间戳的方式返回。

实例:

$file = "test.txt";

outputFileTestInfo( $file );

function outputFileTestInfo( $f ){

if ( ! file_exists( $f ) ){

print "$f does not exist
";

return;

}

print "$f was accessed on ".date( "D d M Y g:i A",fileatime( $f ) )."
";

}

?>

filemtime

filemtime函数返回文件中的数据块上次被写入的时间,也就是说,文件的内容上次被修改的时间。

实例:

$file = "test.txt";

outputFileTestInfo( $file );

/* http://www.manongjc.com/article/1374.html */

function outputFileTestInfo( $f ){

if ( ! file_exists( $f ) ){

print "$f does not exist
";

return;

}

print "$f was modified on ".date( "D d M Y g:i A",filemtime( $f ) )."
";

}

?>

filectime

filectime返回文件上次 inode 被修改的时间,即文件创建时间, 或者在失败时返回 FALSE 。 时间以 Unix 时间戳的方式返回。

$file = "test.txt";

outputFileTestInfo( $file );

function outputFileTestInfo( $f ){

if ( ! file_exists( $f ) ){

print "$f does not exist
";

return;

}

print "$f was changed on ".date( "D d M Y g:i A",filectime( $f ) )."
";

}

?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读