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刪除失敗
";
}
}