Delete the folder and all the files under the folder, delete the folder files
/**
* 删除文件夹及其文件夹下所有文件
*/
public static function deldir($dir) {
//先删除目录下的文件:
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
self::deldir($fullpath);
}
}
}
closedir($dh);
//删除当前文件夹:
if(rmdir($dir)) {
return true;
} else {
return false;
}
}
Copy after login
http://www.bkjia.com/PHPjc/1082221.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1082221.htmlTechArticleDelete the folder and all files under the folder, delete the folder file /*** Delete the folder and all files under it*/public static function deldir($dir) {//Delete the directory first...