有趣生活

当前位置:首页>科技>php目录路径转换php如何创建文件夹

php目录路径转换php如何创建文件夹

发布时间:2026-07-02阅读(0)

导读php如何创建文件夹functiondir_create($path,$mode=0777){if(is_dir($path))returnTRUE;$ft....

php如何创建文件夹function dir_create($path, $mode = 0777){ if (is_dir($path)) return TRUE; $ftp_enable = 0; $path = dir_path($path); $temp = explode(/, $path); $cur_dir = ; $max = count($temp) - 1; for ($i = 0; $i < $max; $i ) { $cur_dir .= $temp[$i] . /; if (@is_dir($cur_dir)) continue; @mkdir($cur_dir, 0777, true); @chmod($cur_dir, 0777); } return is_dir($path);},今天小编就来说说关于php目录路径转换?下面更多详细答案一起来看看吧!

php目录路径转换(php如何创建文件夹)

php目录路径转换

php如何创建文件夹

示例如下:

function dir_create($path, $mode = 0777){ if (is_dir($path)) return TRUE; $ftp_enable = 0; $path = dir_path($path); $temp = explode(/, $path); $cur_dir = ; $max = count($temp) - 1; for ($i = 0; $i < $max; $i ) { $cur_dir .= $temp[$i] . /; if (@is_dir($cur_dir)) continue; @mkdir($cur_dir, 0777, true); @chmod($cur_dir, 0777); } return is_dir($path);}

PHP创建文件夹总结:

1 用PHP5中自带的mkdir 中的一个新的参数 recursive ,通过设置 recursive 为 true 可以实现递归创建目录的目的,但是对PHP4就不行了。

2 自己写的方法中,用mkdirs来创建多级父级目录方式

3 仍然用mkdir很巧妙地来创建

TAGS标签:  目录  路径  转换  如何  创建  php目录路径转换p

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图