How to determine if a folder exists in php and create it if it does not exist

藏色散人
Release: 2023-03-06 12:24:01
Original
5775 people have browsed it

php determines whether the folder exists, and creates it if it does not exist: first create a PHP sample file; then define a mkdirs method; finally use the "mkdirs("aa01");" method to determine the folder and create it Just create it.

How to determine if a folder exists in php and create it if it does not exist

Recommended: "PHP Video Tutorial"

php determines whether the folder exists and then creates it

The code is as follows:

function mkdirs($dir, $mode = 0777) { if (is_dir($dir) || @mkdir($dir, $mode)) return TRUE; if (!mkdirs(dirname($dir), $mode)) return FALSE; return @mkdir($dir, $mode); } mkdirs("aa01");
Copy after login

The default mode is 0777, which means the maximum possible access rights.

The above is the detailed content of How to determine if a folder exists in php and create it if it does not exist. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
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!