common.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 流年 <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // 应用公共文件
  12. /**
  13. * 删除目录以及其下的文件
  14. * @param $directory
  15. * @return bool
  16. */
  17. function removeDir($directory)
  18. {
  19. if (false == is_dir($directory)) {
  20. return false;
  21. }
  22. $handle = opendir($directory);
  23. while (false !== ($file = readdir($handle))) {
  24. if ('.' != $file && '..' != $file) {
  25. is_dir("$directory/$file") ? removeDir("$directory/$file") : @unlink("$directory/$file");
  26. }
  27. }
  28. if (readdir($handle) == false) {
  29. closedir($handle);
  30. rmdir($directory);
  31. }
  32. return true;
  33. }