PHP递归删除缓存文件
/**
* 递归删除缓存文件
* @param $dir 缓存文件路径
*/
function delFileByDir($dir) {
$dh = opendir($dir);
while ($file = readdir($dh)) {
if ($file != "." && $file != "..") {
$fullpath = $dir . "/" . $file;
if (is_dir($fullpath)) {
$this->delFileByDir($fullpath);
} else {
unlink($fullpath);
}
}
}
closedir($dh);
}