📜  PHP | DirectoryIterator getCTime()函数

📅  最后修改于: 2022-05-13 01:56:22.107000             🧑  作者: Mango

PHP | DirectoryIterator getCTime()函数

DirectoryIterator::getCTime()函数是PHP中的一个内置函数,用于获取当前 DirectoryIterator 项的 inode 更改时间。

句法:

int DirectoryIterator::getCTime( void )

参数:此函数不接受任何参数。

返回值:该函数以Unix时间戳格式返回文件的最后更改时间。

下面的程序说明了PHP中的 DirectoryIterator::getCTime()函数:

方案一:

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() . "
";     }        // Move to the next element     $directory->next(); } ?> 

输出:

. | CTime: 1574350718
.. | CTime: 1574350715
dashboard | CTime: 1574350718
img | CTime: 1574350718
webalizer | CTime: 1574350718
xampp | CTime: 1574350718

方案二:

current();
      
    // Display the key, filename and 
    // its inode change time
    echo $dir->key() . " => " . 
        $file->getFilename() . " | CTime: " .
        $dir->getCTime() . "
"; } ?>

输出:

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