Home  >  Article  >  php教程  >  PHP 循环检查创建目录 ,0777

PHP 循环检查创建目录 ,0777

WBOY
WBOYOriginal
2016-06-06 19:49:39764browse

function ckDir($path){ $path = is_dir($path) ? $path:dirname($path); $folderArr = explode(/,$path); $dir = $comma = ; foreach($folderArr as $folder){ $dir .= $comma.$folder; $comma = /; if($dir == . || $dir == ..) continue; if(!is_dir($dir


2011-08-20 更正:上面这个写的太复杂了,下面这个精简版的:

function MkFolder($path){
  if(!is_readable($path)){
    MkFolder( dirname($path) );
    if(!is_file($path)) mkdir($path,0777);
    }
}



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