if (!function_exists('write_file')) {
/**
* 文件写入
* Author:刘星麟
* @param $filePath 文件路径
* @param $fileName 文件名称
* @param $content 写入内容
* @return bool|int
*/
function write_file($filePath, $fileName, $content)
{
//判断文件是否存在,如果不存在则创建文件夹
if (!is_dir($filePath)) {
@mkdir($filePath, 0755, true);
}
$directory_separator = substr($filePath, (strlen($filePath) - 1), 1);
if ($directory_separator != '/') {
$filePath = $filePath . '/';
}
//文件名称
$fileName = $filePath . DIRECTORY_SEPARATOR . $fileName;
return file_put_contents($fileName, $content);
}
}