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

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-05-12 17:47:572215browse

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);
	}
}

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete