_php Tutorials for PHP functions that support multi-level directory creation

Source: Internet
Author: User
Support for multi-level directory built PHP function This function PHP Custom function is a path to create a folder and support multi-level directory instance function Oh.

PHP tutorial functions that support multilevel directory creation
This function PHP Custom function is a path to create a folder and support multi-level directory instance function Oh.

* Create_dir (Create folder path, support multi-level directory);
*/
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;
}
}

See a directory to detect and write file functions

function Htm_w (
$w _dir = ",
$w _filename = ",
$w _content = "
){

$dvs = ";
if ($w _dir && $w _filename && $w _content) {
Number of catalog detections
$w _dir_ex = explode ('/', $w _dir);
$w _new_dir = "; Post-processing 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 number of directories you need to change
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);
}
}
?>


http://www.bkjia.com/PHPjc/444850.html www.bkjia.com true http://www.bkjia.com/PHPjc/444850.html techarticle support for multi-level directory built PHP function This function PHP Custom function is a path to create a folder and support multi-level directory instance function Oh. Support for multi-level directory-based PHP tutorial functions ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.