Home >Backend Development >PHP Tutorial >How to create multi-level directories in php_PHP tutorial

How to create multi-level directories in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:00:431003browse

How to create multi-level directories in php

This article mainly introduces the method of creating multi-level directories in php, involving the skills of operating directories in php, which is of great practical value and is needed Friends can refer to it

The example in this article describes how to create a multi-level directory in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

/*

写出一个能创建多级目录的PHP函数

*/

function createdirlist($path,$mode){

if (is_dir($path)){

//判断目录存在否,存在不创建

echo "目录'" . $path . "'已经存在";

//已经存在则输入路径

}else{ //不存在则创建目录

$re=mkdir($path,$mode,true);

//第三个参数为true即可以创建多极目录

if ($re){

echo "目录创建成功";//目录创建成功

}else{

echo "目录创建失败";

}

}

}

$path="/a/x/cc/cd"; //要创建的目录

$mode=0755; //创建目录的模式,即权限.

createdirlist($path,$mode);//测试

1 2

3

4 5

67 8 9 10 11 12
13
14
15 16 17 18 19 20 21 22
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/973125.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973125.htmlTechArticleHow to create a multi-level directory in PHP This article mainly introduces the method of creating a multi-level directory in PHP, involving PHP operations Directory skills are of great practical value. Friends who need them can refer to this article...
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