定义

fileatime()函数返回指定文件的最后访问时间。

 

语法

PHP fileatime()函数具有以下语法。

fileatime(filename)

 

参数

参数 是否必须 描述
filename 需要。 要检查的文件

 

注意

此函数的结果被缓存。使用clearstatcache()清除缓存。

 

返回值

返回文件上次访问的时间,或失败时为FALSE。时间以Unix时间戳返回。

 

实例

PHP函数fileatime()返回最后访问的时间。

它返回时间的Unix时间戳,然后您需要使用对date()的调用进行转换,如下所示:

<?php
/*
http://www.manongjc.com/article/1781.html
作者:码农教程
*/
     $contacts = \"text.txt\";
     $atime = fileatime($contacts);
     $mtime = filemtime($contacts);

     $atime_str = date(\"F jS Y H:i:s\", $atime);
     $mtime_str = date(\"F jS Y H:i:s\", $mtime);

     print \"File last accessed: $atime_str\\n\";
     print \"File last modified: $mtime_str\\n\";

     echo fileatime(\"test.txt\");
     echo \"\\n\";
     echo \"Last access: \".date(\"F d Y H:i:s.\",fileatime(\"test.txt\"));

?>
收藏 打印