How to remove Directories in PHP This article provides three ways to delete directories in PHP, if you are looking for a delete directory or delete all the files in the PHP code to see it.
PHP Tutorial Delete Directory several methods
This article provides three ways to delete directories in PHP , if you are looking to delete directories or delete all the files in the directory PHP code to see it.
Deletedir ($dir)
{
if (RmDir ($dir) ==false && is_dir ($dir)) {
if ($DP = Opendir ($dir)) {
while (($file =readdir ($DP))! = False) {
if (Is_dir ($file) && $file! = '. ' && $file! = ' ... ') {
Deletedir ($file);
} else {
Unlink ($file);
}
}
Closedir ($DP);
} else {
Exit (' www.aimeige.com.cn not permission ');
}
}
}
Delete directory use RmDir to remove it.
For example, the folder where the current file is located downstream www.bkjia.com/a folder
@ $flag = rmdir ("www.bkjia.com/");
if ($flag)
{echo "www.zhutiai.com delete succeeded";}
Else
{echo "www.bkjia.com delete failed";}
Below is a PHP delete folder and all the files under the folder
function Deldir ($dir) {
$DH =opendir ($dir);
while ($file =readdir ($DH)) {
if ($file! = "." && $file! = "...") {
$fullpath = $dir. " /". $file;
if (!is_dir ($fullpath)) {
Unlink ($fullpath);//mb.php100.com
} else {
Deldir ($fullpath);
}
}
}
Closedir ($DH);
if (RmDir ($dir)) {
return true;
} else {
return false;
}
}
http://www.bkjia.com/PHPjc/445402.html www.bkjia.com true http://www.bkjia.com/PHPjc/445402.html techarticle How to remove Directories in PHP This article provides three ways to delete directories in PHP, if you are looking for a delete directory or delete all the files in the PHP code to see it. PHP Tutorials ...