The file_put_contents () function writes a string to the file and calls fopen (), fwrite (), and fclose () in turn.
Description
Parameter data can be an array (but not a multidimensional array).
From PHP 5.1.0, the data parameter can also be specified as a stream resource, and the cached data stored in the stream will be written to the specified file, similar to the use of the Stream_copy_to_stream () function.
Support for the context parameter is added by the PHP 5.0.0.
return value
The function returns the number of bytes written to the data in the file.
Grammar
File_put_contents (File,data,mode,context)
File required. A file that requires data to be written. If the file does not exist, a new file is created.
Data is optional. Specify the data to be written to the file. Can be a string, array, or data stream.
mode is optional. Specify how to open/write files. Possible values:
File_use_include_path
File_append
Lock_ex
The context is optional. The environment that prescribes the file handle.
The context is a set of options that can modify the behavior of a stream. If NULL is used, it is ignored.
*/
$str = ' original article of this site turn please note from Www.111cn.net ';
$file = ' 111cn.net.txt ';
if (file_put_contents ($file, $str))
{
echo file_get_contents ($file);
&NBSP}
else
{
echo $file, ' cannot create please check permission ';
}
&NBSP
//This article original in Www.111cn.net reprint indicates the Origin
"