Today to save the picture, use the file_put_contents () to save the picture, run a few times, the hair has no data come out, thought that this function did not operate successfully
So I looked at the usage and return value of the function, and found that I returned the output correctly, and then found that it was caused by other reasons.
Now share the following usage of this function:
The file_put_contents () function is the most appropriate choice to write a string to a file or append string content at once.
The file_put_contents () function is used to write a string to a file, successfully returning the number of bytes written to the data in the file, and FALSE if the failure is unsuccessful.
Grammar:
int file_put_contents (string filename, string data [, int flags [, resource context]])
Parameter Description: Parameter description
FileName to write the data to
Data to be written to. The type can be String,array (but not a multidimensional array), or a stream resource
Flags are optional, which specifies how to open/write files. Possible values:
File_use_include_path: Check the built-in path of the filename copy
File_append: Writes data appended to the end of the file
LOCK_EX: Lock the file
Context is optional, and context is a set of options through which you can modify text properties
Example:
Echo file_put_contents ("Test.txt", "This is something.");
?>
To run the example, the browser outputs:
18
The contents of the Test.txt file (in the same directory as the program) are: This is something.
The above describes the File_put_contents image saving function after the return value, including the content of the contents, I hope that the PHP tutorial interested in a friend to help.