Home > Backend Development > PHP Tutorial > How to use the PHP rmdir() function to delete a directory_PHP Tutorial

How to use the PHP rmdir() function to delete a directory_PHP Tutorial

WBOY
Release: 2016-07-15 13:32:43
Original
1107 people have browsed it

For

PHP rmdir() function code:

  1. < ?php
  2. function removeDir($dirName)
  3. {
  4. $result = false;
  5. if(! is_dir($dirName))
  6. {
  7. trigger_error("Directory Name error", E_USER_ERROR);
  8. }
  9. $handle = opendir($dirName);
  10. while(($file = readdir($handle)) !== false)
  11. {
  12. if($file != '.' && $file != '..')
  13. {
  14. $dir = $dirName . DIRECTORY_SEPARATOR . $file;
  15. is_dir($dir) ? removeDir($dir) : unlink($dir);
  16. }
  17. }
  18. closedir($handle);
  19. $result = rmdir($dirName) ? true : false;
  20. return $result;
  21. }
  22. ?>

and above This code is the specific use of the PHP rmdir() function.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446116.htmlTechArticleFor PHP rmdir() function code: ?php functionremoveDir($dirName) { $ result = false ; if(! is_dir($dirName)) { trigger_error(wrong directory name, E_USER_ERROR); } $ handle = opendir...
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