只是好奇
$files = glob(cacheme_directory()."*");
foreach($files as $file)
{
$filemtime=filemtime ($file);
if (time()-$filemtime>= 172800)
{
unlink($file);
}
}
Run Code Online (Sandbox Code Playgroud)
我只是想确定代码是否正确.谢谢.
我写这个PHP脚本删除超过24个小时,较旧的旧文件,但它删除了所有,包括较新的文件:
<?php
$path = 'ftmp/';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ((time()-filectime($path.$file)) < 86400) {
if (preg_match('/\.pdf$/i', $file)) {
unlink($path.$file);
}
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)