Command: File_put_contents ();
Command resolution: File_put_contents (PHP 5)
File_put_contents-Writes a string to a file
Description
int file_put_contents (string filename, string data [, int flags [, resource context]])
and call fopen (), fwrite () and fclose () in turn.
Parameter data can be an array (but not a multidimensional array), which is equivalent to File_put_contents ($filename, Join (', $array)
Since PHP 5.1.0, the data parameter can also be specified as a stream resource, where the stored cache is written to the specified file, similar to the use of the Stream_copy_to_stream () function.
Parameters
FileName
The name of the file to be written to.
Data
The data to write. Types can be String,array or stream resources (as described above).
Flags
Flags can be file_use_include_path,file_append and/or LOCK_EX (get an exclusive lock), but use File_use_include_path with special care.
Context
A context resource.
Write code (the code itself is infallible, but has learned another feature of it):
Copy Code code as follows:
<?php
$contents = "This is the content written using file_put_contents";
$contents 2 = Array ("This is used", "file_put_contents", "command-written content");
File_put_contents ("Html/caceh.txt", $contents);
File_put_contents ("Html/cache2.txt", $contents 2);
?>
Code Analysis: You intend to write a string to the Cache.txt,cache2.txt two files using the file_put_contents command.
Results: New caceh.txt files are added to the HTML file directory, you know ————
Remember: the file_put_contents () function integrates fopen (), fwrite (), fclose () Three functions, in this case the new file is the function of fopen ().