Home > Article > Backend Development > How to write text in php and create the folder if it does not exist
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.
// 安全文件路径,$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!