PHP function that supports multi-level directory creation_PHP tutorial

WBOY
Release: 2016-07-20 11:08:52
Original
742 people have browsed it

PHP function that supports multi-level directory creation. This PHP custom function is a path to create a folder and supports multi-level directory instance functions.

PHP tutorial function that supports multi-level directory creation
This function PHP custom function is a path to create a folder and supports multi-level directory instance functions.

* create_dir (path to create a folder, supports multi-level directories);
*/
function create_dir($dir_adds='') {
$falg = true;
$dir_adds = trim($dir_adds);
if($dir_adds!=''){
$dir_adds = str_replace(array('//','',''),'/' ,$dir_adds);
if (!is_dir($dir_adds)) {
$temp = explode('/',$dir_adds);
$cur_dir = '';
for($i =0;$i $cur_dir .= $temp[$i].'/';
if (!@is_dir($cur_dir)) {
if(!@mkdir($cur_dir,0777))
$falg = false;
}
}
}
return $falg;
}
}

//Look at a directory detection and writing file function

function htm_w(
$w_dir = '',
$w_filename = '',
$w_content = ''
){

$dvs = '';
if($w_dir && $w_filename && $w_content){
//Number of directory detections
$w_dir_ex = explode('/ ',$w_dir);
$w_new_dir = ''; //Processed write directory
unset($dvs,$fdk,$fdv,$w_dir_len);
foreach((array)$ w_dir_ex as $dvs){
if(trim($dvs) && $dvs!='..'){
$w_dir_len .= '../';
$w_new_dir .= $dvs. '/';
if (!@is_dir($w_new_dir)) @mkdir($w_new_dir, 0777);
}
}


//Get the directory that needs to be changed Number
foreach((array)$this->filedir as $fdk=>$fdv){
$w_content = str_replace($fdv,$w_dir_len.str_replace('../','', $fdv),$w_content);
}
$this->writer($w_dir.$w_filename,$w_content);
}
}
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444850.htmlTechArticlePHP function that supports multi-level directory creation. This function php custom function is a path to create a folder and supports Multi-level directory instance function. PHP tutorial function that supports multi-level directory creation...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template