search
Homephp教程php手册支持多级目录建立的php函数

支持多级目录建立的php函数

Jun 13, 2016 am 11:24 AM
phpfunctionEstablishsupportfolderpaymentofTable of contentscustomizepath

支持多级目录建立的php函数本函数php自定义函数是一款建立文件夹的路径并且支持多级目录实例函数哦。

支持多级目录建立的php教程函数
本函数php自定义函数是一款建立文件夹的路径并且支持多级目录实例函数哦。

 * create_dir(建立文件夹的路径,支持多级目录);
 */
 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;
  }
 }
 
 //看一款目录检测并写文件函数
 
 function htm_w(
    $w_dir = '',
    $w_filename = '',
    $w_content = ''
   ){

  $dvs  = '';
  if($w_dir && $w_filename && $w_content){
   //目录检测数量
   $w_dir_ex  = explode('/',$w_dir);
   $w_new_dir = ''; //处理后的写入目录
   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);
    }
   }


   //获得需要更改的目录数
   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);
  }
 }
 ?>


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft