Remove all files, folders and their subfolders with php [duplicate]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Delete directory with files in it? 30 answers I need a script which can remove a whole directory with all their subfolders, files and etc. I tried with this function which I found in internet before few months ago but it not work completely. function deleteFile($dir) { if(substr($dir, strlen($dir)-1, 1) != '/') { $dir .= '/'; } if($handle = opendir($dir)) { while($obj = readdir($handle)) { if($obj != '.' && $obj != '..') { if(is_dir($dir.$obj)) { if(!deleteFile($dir.$obj)) { echo $dir.$obj."<br />";