php删除檔案:unlink()函數
<?php
echo unlink('test.doc');
?>
php删除檔案夾及其下面的檔案:
function deldir($dir) {
//先删除目錄下的檔案:
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
deldir($fullpath);
}
}
}
closedir($dh);
//删除目前檔案夾:
if(rmdir($dir)) {
return true;
} else {
return false;
}
本文轉自許琴 51CTO部落格,原文連結:http://blog.51cto.com/xuqin/1130186,如需轉載請自行聯系原作者