DirectoryIterator::getCTime()函數是PHP中的內置函數,用於獲取當前DirectoryIterator項的inode更改時間。
用法:
int DirectoryIterator::getCTime( void )
參數:該函數不接受任何參數。
返回值:此函數以Unix時間戳格式返回文件的最後更改時間。
以下示例程序旨在說明PHP中的DirectoryIterator::getCTime()函數:
示例1:
<?php
// Create a directory Iterator
$directory = new DirectoryIterator(dirname(__FILE__));
// Loop runs while directory is valid
while ($directory->valid()) {
// Check if the element is directory
if ($directory->isDir()) {
// Store the current element
$file = $directory->current();
// Display the file name and
// inode change time
echo $file->getFilename() . " | CTime: "
. $directory->getCTime() . "<br>";
}
// Move to the next element
$directory->next();
}
?>
輸出:
. | CTime: 1574350718 .. | CTime: 1574350715 dashboard | CTime: 1574350718 img | CTime: 1574350718 webalizer | CTime: 1574350718 xampp | CTime: 1574350718
示例2:
<?php
// Create a directory Iterator
$directory = new DirectoryIterator(dirname(__FILE__));
// Loop runs for each element of directory
foreach($directory as $dir) {
// Store the current element of directory
$file = $directory->current();
// Display the key, filename and
// its inode change time
echo $dir->key() . " => " .
$file->getFilename() . " | CTime: " .
$dir->getCTime() . "<br>";
}
?>
輸出:
0 => . | CTime: 1574350718 1 => .. | CTime: 1574350715 2 => applications.html | CTime: 1574350724 3 => bitnami.css | CTime: 1574350724 4 => dashboard | CTime: 1574350718 5 => favicon.ico | CTime: 1574350724 6 => geeks.PNG | CTime: 1574478578 7 => gfg.php | CTime: 1574351394 8 => img | CTime: 1574350718 9 => index.php | CTime: 1574350723 10 => webalizer | CTime: 1574350718 11 => xampp | CTime: 1574350718
注意:此函數的輸出取決於服務器文件夾的內容。
參考: https://www.php.net/manual/en/directoryiterator.getctime.php
相關用法
- PHP SplFileInfo getCTime()用法及代碼示例
- PHP DirectoryIterator key()用法及代碼示例
- PHP DirectoryIterator next()用法及代碼示例
- PHP DirectoryIterator getBasename()用法及代碼示例
- PHP DirectoryIterator getPath()用法及代碼示例
- PHP DirectoryIterator __toString()用法及代碼示例
- PHP DirectoryIterator getFilename()用法及代碼示例
- PHP DirectoryIterator getExtension()用法及代碼示例
- PHP DirectoryIterator getMTime()用法及代碼示例
- PHP DirectoryIterator __construct()用法及代碼示例
- PHP DirectoryIterator isDot()用法及代碼示例
- PHP DirectoryIterator current()用法及代碼示例
- PHP DirectoryIterator isExecutable()用法及代碼示例
- PHP DirectoryIterator isFile()用法及代碼示例
- PHP DirectoryIterator getATime()用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 PHP | DirectoryIterator getCTime() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。