SplFileInfo::getATime()函数是PHP中标准PHP库(SPL)的内置函数,用于获取文件的最后访问时间。
用法:
int SplFileInfo::getATime( void )
参数:该函数不接受任何参数。
返回值:该函数返回文件的最后访问时间。
以下示例程序旨在说明PHP中的SplFileInfo::getATime()函数:
示例1:
// PHP Program to illustrate
// Splfileinfo::getATime() function
// Create new SPlFileInfo Object
$file = new SplFileInfo('demo1.php');
// Print result
echo (date("F d Y H:i:s.", $file->getATime()));
?>
输出:
October 14 2018 03:24:12.
示例2:
// PHP program to use array to check multiple files
$GFG = array(
"/home/rajvir/Desktop/GeeksforGeeks/dummy.php",
"/home/rajvir/Desktop/gfg.txt",
"/var/www/html/gfg.php",
"demo.php"
);
foreach ($GFG as &$file) {
// Create new SPlFileInfo Object
$file = new SplFileInfo('demo1.php');
// Print result
echo date("F d Y H:i:s.", $file->getATime()) . "";
}
?>
输出:
October 14 2018 03:24:12.
October 14 2018 03:24:12.
October 14 2018 03:24:12.
October 14 2018 03:24:12.