Heim  >  Artikel  >  php教程  >  PHP创建多级目录(多层级文件夹)其实很简单,无需自写函数

PHP创建多级目录(多层级文件夹)其实很简单,无需自写函数

WBOY
WBOYOriginal
2016-06-06 19:40:452977Durchsuche

偶然看到网上很多PHP 创建 多级 目录 的 函数 ,他们都说mkdir()只能 创建 单级 目录 (也就是执行一次只能 创建 一个 文件夹 ,无法 创建 多个嵌套 文件夹 ) 但实际上自PHP5.0版本之后,mkdir有了第三个参数 recursive ,对也就是递归的意思。只要该参数为

偶然看到网上很多PHP创建多级目录函数,他们都说mkdir()只能创建单级目录(也就是执行一次只能创建一个文件夹,无法创建多个嵌套文件夹

但实际上自PHP5.0版本之后,mkdir有了第三个参数recursive,对也就是递归的意思。只要该参数值为true即可创建多级目录

例:mkdir("one/two/three/four/dir",0777,true);

快去试试吧

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