Home  >  Article  >  Backend Development  >  A general method for recursively creating multi-level directories in PHP

A general method for recursively creating multi-level directories in PHP

WBOY
WBOYOriginal
2016-07-25 08:45:28850browse
  1. /**
  2. *
  3. +------------------------------------------------- -----------------------
  4. * Description Create directory recursively
  5. +------------------------ ------------------------------------------------
  6. * @param string $dir Directory that needs innovation
  7. +--------------------------------------------- --------------------------------
  8. * @return If the directory exists or is created successfully, it returns TRUE
  9. +---- -------------------------------------------------- ----------------
  10. * @author gongwen
  11. +-------------------------------- ---------------------------------------
  12. */
  13. function mkdirs($dir, $mode = 0777){
  14. if (is_dir($dir) || mkdir($dir, $mode)) return TRUE;
  15. if (!mkdirs(address($dir), $mode)) return FALSE;
  16. return mkdir($dir, $mode);
  17. }
copy code

PHP


Statement:
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