Home > php教程 > php手册 > php循环创建目录示例分享(php创建多级目录)

php循环创建目录示例分享(php创建多级目录)

WBOY
Release: 2016-06-06 20:24:24
Original
1365 people have browsed it

这篇文章主要介绍了php循环创建目录示例,原理就是不断的尝试创建上层目录,依此类推,需要的朋友可以参考下

复制代码 代码如下:


function mk_dir($dir, $mod = 0777)
{
  if(!is_dir($dir) || mkdir($dir, $mod))
  {
    if(!mk_dir(dirname($dir, $mod)))
    {
      return false;
    }
  }
  return mkdir($dir, $mod);
}


原理:就是不断的尝试创建上层目录,依此类推 ,
Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template