PHP 循环检查创建目录 ,0777
程序员文章站
2022-05-08 19:28:50
...
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); } }