Heim > Artikel > Backend-Entwicklung > php删除目录的函数_PHP教程
php删除目录的函数
实例应用做删除有文件目录的函数:
function scmulu($mlming)
{
$dkml = opendir($mlming);
readdir($dkml);
readdir($dkml);
while(($wj = readdir($dkml))!==false)
{
$wj = $mlming.DIRECTORY_SEPARATOR.$wj;
if(is_dir($wj))
{
scmulu($wj);
}else
{
if(unlink($wj))
{
echo "文件$wj删除成功
";
}else
{
echo "文件$wj删除失败
";
}
}
}
closedir($dkml);
if(rmdir($mlming))
{
echo "目录$mlming删除成功
";
}else
{
echo "目录$mlming删除失败
";
}
}