public function delDirAndFile($path = '', $delDir = true)
{
if (is_dir($path)) {
$handle = opendir($path);
if ($handle) {
while (false !== ($item = readdir($handle))) {
if ($item != '.' && $item != '..') {
is_dir("$path/$item") ? delDirAndFile("$path/$item", $delDir) : unlink("$path/$item");
}
}
closedir($handle);
if ($delDir) {
return rmdir($path);
}
}
} else {
if (file_exists($path)) {
echo $path;
return unlink($path);
} else {
return false;
}
}
}
PHP 删除文件
最新推荐文章于 2023-07-03 09:47:23 发布