Heim  >  Artikel  >  Backend-Entwicklung  >  php创建多级目录(递归创建目录)方法示例

php创建多级目录(递归创建目录)方法示例

WBOY
WBOYOriginal
2016-07-25 08:51:161216Durchsuche
php怎么创建多级目录,php创建多级目录的实例代码,以及php递归创建目录的方法示例,通过例子介绍了php操作文件目录的具体方法。

一、php创建多级目录的方法。

复制代码 代码示例: 二、php创建多级目录代码

php的多级目录实现代码:

复制代码 代码示例:

function createFolder($path) { if (!file_exists($path)) { createFolder(dirname($path));

mkdir($path, 0777); } } createFolder("2007/3/4");//在当前目录下创建2007/3/4的目录结构.

三、php递归创建目录的方法

php递归创建目录的方法,采用递归创建目录的技巧,三元运算符的实现方法

例子,php递归创建目录的方法

复制代码 代码示例:

换成三元运算,代码如下:



Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn