Filesystem 函数
PHP 手册

fileatime

(PHP 4, PHP 5)

fileatime取得文件的上次访问时间

说明

int fileatime ( string $filename )

返回文件上次被访问的时间,如果出错则返回 FALSE。时间以 Unix 时间戳的方式返回。

注意:一个文件的 atime 应该在不论何时读取了此文件中的数据块时被更改。当一个应用程序定期访问大量文件或目录时很影响性能。有些 Unix 文件系统可以在加载时关闭 atime 的更新以提高这类程序的性能。USENET 新闻组假脱机是一个常见的例子。在这种文件系统下本函数没有用处。

Note: 本函数的结果会被缓存。更多信息参见 clearstatcache()

Tip

PHP 5.0.0 起本函数也可被某些 URL wrapper 使用。参考支持的协议/封装协议列表 来看哪些 wrapper 支持 stat() 系列函数的功能。

Example #1 fileatime() 例子

<?php

// 输出类似:somefile.txt was last accessed: December 29 2002 22:16:23.

$filename 'somefile.txt';
if (
file_exists($filename)) {
    echo 
"$filename was last accessed: " date("F d Y H:i:s."fileatime($filename));
}

?>

参见 filemtime()fileinode()date()


Filesystem 函数
PHP 手册