Home > Backend Development > PHP Problem > How to write text in php and create the folder if it does not exist

How to write text in php and create the folder if it does not exist

醉折花枝作酒筹
Release: 2023-03-09 15:56:02
forward
2213 people have browsed it

This article will introduce you to the method of writing text in PHP and creating a folder if it does not exist. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to write text in php and create the folder if it does not exist

// 安全文件路径,$fileName:完成文件路径
function securityFilePath($fileName,$read_write = '0777'){
	$path = dirname($fileName);
	if(!file_exists($path)){// 判断路径是否存在,如果不存在则mkdir创建,并写入权限
		mkdir ($path,$read_write,true);
	}
}
Copy after login

Recommended learning: php video tutorial

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

Related labels:
php
source:csdn.net
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template