最近會使用到「取得檔案最後修改的時間」,從PHP手冊發現有兩個功能描述幾乎一模一樣的函式filectime()與filemtime,當然很自然的好奇倒底是差在哪邊,所以就用G大仙查了一下,很慶幸在「這篇討論文」有找到由coopster所提出的解答:),而且還特別說明了fileatime這個函式

fileatime

The atime of a file is supposed to change whenever the data blocks of a file are being read. This can be costly performancewise when an application regularly accesses a very large number of files or directories. Some Unix filesystems can be mounted with atime updates disabled to increase the performance of such applications; USENET news spools are a common example. On such filesystems this function will be useless.

(無論這個檔案是否正被讀取,atime會不斷去取得檔案最後存取的時間,但這可能會佔去大量的系統資源,一些UNIX的檔案系統會將此函式設定無效來增加應用程式的效能)

filectime

In most Unix filesystems, a file is considered changed when its inode data is changed; that is, when the permissions, owner, group, or other metadata from the inode is updated. Note also that in some Unix texts the ctime of a file is referred to as being the creation time of the file. This is wrong. There is no creation time for Unix files in most Unix filesystems.

(當檔案的權限被異動時,就會更新檔案的最後修改時間,注意,有些時候ctime被拿來當做檔案的建立時間,這是錯誤的,在大部分的UNIX系統檔案沒有所謂的建立時間)

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.

(只有當檔案的被異動後,也就是資料區塊被寫入時,才會更新檔案的最後修改時間)

低溫烘培 發表在 痞客邦 PIXNET 留言(0) 人氣()