PHP写入文件接口

public static function writeFile($filePath = '',$ctt = '')
{
$dir_name = dirname($filePath);
//目录不存在就创建
if(!file_exists($dir_name))
{ mkdir($dir_name,0777,true);} //0755
//打开文件资源通道 不存在则自动创建
$fp = fopen($filePath,"w");
//写入文件
fwrite($fp,$ctt);
//关闭资源通道
fclose($fp);
}

posted @ 2019-10-30 13:59  路人jiaer  阅读(269)  评论(0)    收藏  举报