PHP deletes a folder and all files under it

WBOY
Release: 2016-08-08 09:25:04
Original
1044 people have browsed it


function deldir($dir) {
//Delete the files in the directory first:
$dh=opendir($dir);
while ($file=readdir($ dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir ($fullpath)) {
                                                                                                         }
}
closedir($dh) ;
//Delete the current folder:
if(rmdir($dir)) {
  return true;
} else {
  return false;
}
}
?>
The above introduces PHP to delete a folder and all files under the folder, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template