且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查目录内容是否已使用 PHP 更改?

更新时间:2023-11-28 12:03:28

呃.我只是存储目录列表的 md5.如果内容改变,md5(directory-listing) 也会改变.您可能遇到非常偶然的 md5 冲突,但我认为这种机会已经很小了..
或者,您可以在该目录中存储一个包含上次修改"日期的小文件.但我会选择 md5.

Uh. I'd simply store the md5 of a directory listing. If the contents change, the md5(directory-listing) will change. You might get the very occasional md5 ***, but I think that chance is tiny enough..
Alternatively, you could store a little file in that directory that contains the "last modified" date. But I'd go with md5.

附注.再想一想,看看您如何看待请求和散列目录列表的性能(缓存)可能不是完全***的..

PS. on second thought, seeing as how you're looking at performance (caching) requesting and hashing the directory listing might not be entirely optimal..