php 中 fileatime 和 filectime 之间的区别

difference between fileatime and filectime in php

在 php 手册中,fileatime 被定义为 'last access time of a file'。但在我的代码中,我打开并阅读了文件 content.But fileatime 给了我一个回到 2 月的日期 16.Which 表示我上次访问该文件是在 2 月 16 日 ??。但是我正确访问了该文件 now.Why 它没有给我当前日期??

set_include_path('c://Users/shimantta/Desktop/');
$file='hehe.txt';
$open=fopen($file,'r');
echo fread($open,filesize($file)).'</br>';
echo "Last modified: ".date("F d Y H:i:s.",filemtime($file)).'</br>';
echo "Last modified: ".date("F d Y H:i:s.",fileatime($file)).'</br>';
echo "Last modified: ".date("F d Y H:i:s.",filemtime($file));

i am going to be copied here

Last modified: February 21 2015 19:57:21.

Last modified: February 16 2015 05:56:16.

Last modified: February 21 2015 19:57:21.

filemtime() 返回上次更改内容的位置。

以及手册中的引述:

This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed.

编辑:

现在我明白你问的是 fileatime()fopen() 没有按照您预期的修改时间更新。您想使用 touch() 来更新修改时间。

文件访问时间应该是最后一次访问文件。

问题是,在今天的许多系统上,访问时间都没有维护。例如,在安装(例如 fstab)时,可以声明访问时间根本没有更新。

在许多系统上,此功能被禁用,因为 SSD 会磨损得更快,这时通常会进行小的更改,例如更改文件的访问时间。我猜,你得到的访问时间就是创建时间,因为在创建时时间被写入一次并且永远不会更新。

因此,您只有修改时间和创建时间(也应该作为单独的时间戳提供)可用于一个文件。