/** * Recursive Create directory * @param [string] $path [created directory] * @return [Type] [description] */function Mk_dir ($path) {//If directory exists return t Ureif (Is_dir ($path)) {return true;} If the parent directory exists create directory if (Is_dir (DirName ($path))) {return mkdir ($path);} Recursively finds the parent directory Mk_dir (dirname ($path)); return mkdir ($path);}
function Mk_dir ($path) {//directory exists return Tureif (Is_dir ($path)) {return true;} Parent directory exists or recursively finds parent directory, creates directory return Is_dir (dirname ($path)) | | Mk_dir (DirName ($path))? mkdir ($path): "false";}
/** * Iterate to create a directory (the iteration I understand is the process from minimum accumulation to maximum) * @param [string] $path [Create directory name] * @return [Type] [description] */function Mk_di R ($path) {$arr = array ();//The directory decomposition is stored in the array while (!is_dir ($path)) {Array_unshift ($arr, $path);//Inserts an element into the array header $path = DirName ($ path);} if (empty ($arr)) {return ture;} foreach ($arr as $v) {mkdir ($v);}}
After php5 you can use the mkdir third parameter, recursively create a directory mkdir ("directory Name", 0777,true);
function Deldir ($path) {if (!is_dir ($path)) {return null;} $DH = Opendir ($path), while (($row = Readdir ($DH))!== false) {if ($row = = "." | | $row = = "...") {continue;} if (!is_dir ($path. "/" . $row) {unlink ($path. "/" . $row);} Else{deldir ($path. "/" . $row);}} Closedir ($DH); rmdir ($path); return true; Will output 1} on the page
PHP Recursive Create directory