Home > Backend Development > PHP Tutorial > Is there still a problem with deleting the directory and the files under it? I'll give you a written function_PHP Tutorial

Is there still a problem with deleting the directory and the files under it? I'll give you a written function_PHP Tutorial

WBOY
Release: 2016-07-13 16:54:22
Original
766 people have browsed it

    /**
* c_function::dir_delete()
* Delete directory
* @param $file directory name (without /)
* @return
*/
     function dir_delete($file)
     {
        if(file_exists($file))
        {
       if(is_dir($file))
       {
           $handle =opendir($file);
           while(false!==($filename=readdir($handle)))
           {
          if($filename!="."&&$filename!="..")$this->dir_delete($file."/".$filename);
           }
           closedir($handle);
           rmdir($file);
           return true;
       }
       else
       {
           unlink($file);
       }
        }
    }
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631790.htmlTechArticle?php /*** c_function::dir_delete() * Delete directory * @param $file directory name (without /) * @return*/ function dir_delete($file) { if(file_exists($file)) { if(is_dir($file)) { $handle =...
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