file_put_contents()
将一个字符串写入文件
和依次调用 fopen(),fwrite() 以及 fclose() 功能一样。
file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int
If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set.
$fileName = test.txt;
$file = fopen($fileName, 'a+');
fwrite($file, 'test');
fclose($file);
chmod($fileName, 0777);
$fileName = test.txt;
file_put_contents($fileName, 'test');