* Path to the file where to write the data. *

* @param mixed $data

* The data to write. Can be either a string, an * array or a stream resource. *

*

* If data is a stream resource, the * remaining buffer of that stream will be copied to the specified file. * This is similar with using stream_copy_to_stream. *

*

* You can also specify the data parameter as a single * dimension array. This is equivalent to * file_put_contents($filename, implode('', $array)). *

* @return int|bool The function returns the number of bytes that were written to the file, or * false on failure. * @since 5.0 */ public static function filePutContents($filename, $data, $flags = 0, $context = null) { $dir = dirname($filename); self::mkDir($dir); return file_put_contents($filename, $data, $flags, $context); } /** * 创建目录(递归) * @return bool true on success or false on failure. */ public static function mkDir($dir, $mode = 0777) { return is_dir($dir) or self::mkDir(dirname($dir), $mode) and mkdir($dir, $mode); } }