Home >Backend Development >PHP Tutorial >PHP method example of creating multi-level directories (recursively creating directories)

PHP method example of creating multi-level directories (recursively creating directories)

WBOY
WBOYOriginal
2016-07-25 08:51:161267browse
How to create multi-level directories in PHP, example code for creating multi-level directories in PHP, and examples of how to create directories recursively in PHP. Through examples, the specific methods of operating file directories in PHP are introduced.

1. How to create multi-level directories in PHP.

Copy code Code example: 2. PHP code to create multi-level directory

php multi-level directory implementation code:

Copy code Code example:

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

mkdir($path, 0777); } } createFolder("2007/3/4");//Create the directory structure of 2007/3/4 in the current directory.

3. How to recursively create a directory in php

How to create a directory recursively in PHP, using techniques to create directories recursively, and how to implement the ternary operator

Example, how to create a directory recursively in PHP:

Copy code Code example:

Replaced with ternary operation, the code is as follows:



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