Home> php教程> php手册> body text

如何运用PHP rmdir()函数删除目录

WBOY
Release: 2016-06-13 11:09:42
Original
796 people have browsed it

对于

PHP rmdir()函数代码:

  1. ?php
  2. function removeDir($dirName)
  3. {
  4. $result=false;
  5. if(! is_dir($dirName))
  6. {
  7. trigger_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. ?>

以上这段代码就是PHP rmdir()函数的具体使用方法。


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 Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!