Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-06 19:40:45
Original
2989 people have browsed it

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

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

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

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

快去试试吧

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!