file_put_contents image save function return value after success

WBOY
Release: 2016-07-28 08:27:50
Original
1692 people have browsed it

When I saved the image today, I used file_put_contents() to save the image. I ran it several times, but no data came out. I thought it was because the function did not operate successfully. So I checked the usage and return value of this function and found that The returns I output were all correct, but later I found out that it was caused by other reasons. Now let me share the usage of this function:

file_put_contents() function is the most suitable choice for writing strings or appending string contents to a file at one time. The

file_put_contents() function is used to write a string into a file, and returns the number of bytes of data written to the file successfully, otherwise it returns FALSE.

Syntax:

int file_put_contents (string filename, string data [, int flags [, resource context]])

Parameter description: Parameter Description
filename The name of the file to write data to
data The data to be written. The type can be string, array (but not multi-dimensional array), or stream resource
flags are optional and specify how to open/write the file. Possible values:
FILE_USE_INCLUDE_PATH: Check the built-in path for a copy of filename

FILE_APPEND: Write data by appending to the end of the file
LOCK_EX: Lock the file

context Optional, Context is a set of options that can be modified Text attribute Example:
echo file_put_contents("test.txt", "This is something.");
?>
Run this example, the browser output:
18
And the test.txt file ( In the same directory as the program) the content is: This is something..



The above has introduced the return value of the file_put_contents image saving function after success, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!