DirectoryIterator::getATime()函数是PHP中的内置函数,用于获取当前DirectoryIterator项的最后访问时间。
用法:
int DirectoryIterator::getATime( void )
参数:该函数不接受任何参数。
返回值:此函数以Unix时间戳记返回上次访问文件的时间。
以下示例程序旨在说明PHP中的DirectoryIterator::getATime()函数:
示例1:
<?php
// Create a directory Iterator
$directory = new DirectoryIterator(dirname(__FILE__));
// Loop runs while directory is valid
while ($directory->valid()) {
// Check for directory element
if ($directory->isDir()) {
$file = $directory->current();
// Display the filename and last accessed time
echo $file->getFilename() . " | ATime: "
. $directory->getATime() . "<br>";
}
// Move to the next element
$directory->next();
}
?>
输出:
. | ATime: 1574654324 .. | ATime: 1574540515 dashboard | ATime: 1574350724 img | ATime: 1574350724 webalizer | ATime: 1574350718 xampp | ATime: 1574350724
示例2:
<?php
// Create a directory Iterator
$directory = new DirectoryIterator(dirname(__FILE__));
// Loop runs for each element of directory
foreach($directory as $dir) {
$file = $directory->current();
// Display the key, filename and its
// last accessed time
echo $dir->key() . " => " .
$file->getFilename() . " | ATime: " .
$dir->getATime() . "<br>";
}
?>
输出:
0 => . | ATime: 1574654324 1 => .. | ATime: 1574540515 2 => applications.html | ATime: 1574350724 3 => bitnami.css | ATime: 1574350724 4 => dashboard | ATime: 1574350724 5 => favicon.ico | ATime: 1574350724 6 => geeks.PNG | ATime: 1574478578 7 => gfg.php | ATime: 1574654749 8 => img | ATime: 1574350724 9 => index.php | ATime: 1574350723 10 => Sublime Text Build 3211 x64 Setup.exe | ATime: 1574654324 11 => webalizer | ATime: 1574350718 12 => xampp | ATime: 1574350724
注意:此函数的输出取决于服务器文件夹的内容。
参考: https://www.php.net/manual/en/directoryiterator.getatime.php
相关用法
- PHP SplFileInfo getATime()用法及代码示例
- PHP DirectoryIterator key()用法及代码示例
- PHP DirectoryIterator next()用法及代码示例
- PHP DirectoryIterator __toString()用法及代码示例
- PHP DirectoryIterator getPath()用法及代码示例
- PHP DirectoryIterator getMTime()用法及代码示例
- PHP DirectoryIterator getCTime()用法及代码示例
- PHP DirectoryIterator getFilename()用法及代码示例
- PHP DirectoryIterator getExtension()用法及代码示例
- PHP DirectoryIterator isDot()用法及代码示例
- PHP DirectoryIterator current()用法及代码示例
- PHP DirectoryIterator isExecutable()用法及代码示例
- PHP DirectoryIterator isFile()用法及代码示例
- PHP DirectoryIterator __construct()用法及代码示例
- PHP DirectoryIterator getBasename()用法及代码示例
注:本文由纯净天空筛选整理自jit_t大神的英文原创作品 PHP | DirectoryIterator getATime() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。