File_put_contents image save function after successful return value

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.