PHP fileatime()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

The fileatime() function returns the last access time of the specified file.

If successful, the function returns the file's last access time as a Unix timestamp. If it fails, it returns FALSE.

Syntax

fileatime(filename)

Parameter Description
filename Required. Specifies the file to be checked.


Tips and Notes

Note:The results of this function are cached. Use clearstatcache() to clear the cache.

Note:The access time of a file should be changed whenever a data block in the file is read. Some Unix systems disable access time updates because it greatly affects performance when an application periodically accesses a large number of files; disabling access time updates can improve the performance of such programs. USENET newsgroup spooling is a common example. On such file systems, this function is useless.


Example

<?php
echo fileatime("test.txt");
echo "<br />";
echo "Last access: ".date("F d Y H:i:s.",fileatime("test.txt"));
?>

The above code will output:

1140684501
Last access: February 23 2006 09:48:21.


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions