Home  >  Article  >  Backend Development  >  PHP 高速生成目录树

PHP 高速生成目录树

WBOY
WBOYOriginal
2016-06-13 11:00:581130browse

PHP 快速生成目录树

bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context ]]] )


尝试新建一个由 pathname 指定的目录。

recursive 参数是 PHP 5.0.0 添加的。这个参数很方便,如果将 recursive 设置为 true,mkdir函数会将给定的pathname递归创建好。

下面也给出 php 4 中的解决方法:
function mkdirs($path , $mode = 0755 ){           if(!is_dir($path)){               mkdirs(dirname($path),$mode);               mkdir($path,$mode);           }           return true;       }  
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