PHP built-in function File_put_content (), writes data to a file, appends content with the File_append parameter

Source: Internet
Author: User
<span id="Label3"></p><p><p>File_put_contents (filename,data,flags,context)</p></p><p><p>Enter the parameter description:</p></p> <table style="height: 84px; width: 542px;" border="2" align="left"> <tbody> <tr> <td>Parameters</td> <td>Description</td> </tr> <tr> <td>FileName</td> <td>The file name to write the data to</td> </tr> <tr> <td>Data</td> <td>The data to Write. The type can be String,array (but not a multidimensional array), or a stream resource</td> </tr> <tr> <td>Flags</td> <td>optional, which specifies how to Open/write files. Possible values: <ol> <li>File_use_include_path: check the built-in path of the filename copy</li> <li>File_append: writes data appended to the end of the file</li> <li>Lock_ex: Lock the file</li> </ol></td> </tr> <tr> <td>Context</td> <td>optional, context is a set of options through which you can modify text properties</td> </tr> </tbody> </table><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;"></p></p><p style="text-align: left;"><p style="text-align: left;">File_put_contents default is to re-write the file, replacing the original Value. When the flags parameter value is set to file_append, the new data is written in such a way that the content is appended to the contents of the existing File.</p></p><p style="text-align: left;"><p style="text-align: left;">The behavior of file_put_contents () is actually equal to calling fopen (), fwrite (), and fclose () functions in Turn.</p></p><p style="text-align: left;"><p style="text-align: left;">eg.</p></p><p style="text-align: left;"><p style="text-align: left;"><?php</p></p><p style="text-align: left;"><p style="text-align: left;">File_put_contents ("result.txt", "hello", file_append);</p></p><p style="text-align: left;"><p style="text-align: left;"><em id="__mceDel">File_put_contents ("result.txt", "world", file_append);<br>?></em></p></p><p><p>PHP built-in function File_put_content (), writes data to a file, appends content with the File_append parameter</p></p></span>

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.