Home > Backend Development > PHP Tutorial > PHP loop to create multi-level directory example

PHP loop to create multi-level directory example

WBOY
Release: 2016-07-25 08:54:06
Original
1227 people have browsed it
  1. function mk_dir($dir, $mod = 0777)
  2. {
  3.  if(!is_dir($dir) || mkdir($dir, $mod))
  4.  {
  5.   if(!mk_dir (dirname($dir, $mod)))
  6.    {
  7.    return false;
  8.   }
  9.   }
  10.   return mkdir($dir, $mod);
  11. }
Copy code

Principle: Keep trying to create upper-level directories, So on and so forth.



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