/*
 * 连续建目录
 * string $dir 目录字符串
 * int $mode 权限数字
 * 返回:顺利创建或者全部已建返回true,其它方式返回false
 */
function makeDir( $dir_path, $mode = "0777" ) {
    //如:路径("c:/testweb/wap/home.php"), 我们要创建的目录》c:/testweb/wap,所以在上面$dir_path='c:testweb/wap'即可
    if( ! $dir_path ) return 0;
    $dir_path = str_replace( "\\", "/", $dir_path );
    $mdir = "";
    foreach( explode( "/", $dir_path ) as $val ) {
        $mdir .= $val."/";
        if( $val == ".." || $val == "." || trim( $val ) == "" ) continue;
        if( ! file_exists( $mdir ) ) {
            if(!@mkdir( $mdir, $mode )){
                return false;
            }
        }
    }
    return true;
}

 

相关文章:

  • 2021-12-28
  • 2021-12-30
  • 2021-06-12
  • 2021-08-07
  • 2021-10-26
  • 2022-12-23
  • 2021-06-05
  • 2021-05-28
猜你喜欢
  • 2022-12-23
  • 2021-10-18
  • 2021-06-13
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2021-10-22
相关资源
相似解决方案