关注公众号:青山有路

php 清除一天前的文件

php admin 7年前 (2018-01-03) 1236次浏览 已收录 0个评论 扫描二维码

function read_all ($dir){

if(!is_dir($dir)) return false;

$handle = opendir($dir);

if($handle){

while(($fl = readdir($handle)) !== false){

$temp = $dir.$fl;

//如果不加  $fl!=’.’ && $fl != ‘..’  则会造成把$dir的父级目录也读取出来

if(is_dir($temp) && $fl!=’.’ && $fl != ‘..’){

echo ‘目录:’.$temp.'<br>’;

read_all($temp);

}else{

if($fl!=’.’ && $fl != ‘..’){

echo ‘文件:’.$temp.'<br>’;

$modifytime = filemtime($temp);

if($modifytime<(time()-86400)){

unlink($temp);

}

}

}

}

}

// return $arr;

}


版权所有丨如未注明 , 均为原创 , 转载请注明php 清除一天前的文件
喜欢 (2)

Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/gaowenjie.cc/wp-content/themes/Git-alpha/comments.php on line 17
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到