PHP txt operation, adding the class capacity

Source: Internet
Author: User

<?PHP$FR=fopen("./data/test.txt", ' a '); //fopen (position, open mode)    if(!$FR)        {            Echo"Error"; Exit; }            fwrite($FR, "line1". " \ n "); //Insert Content    fwrite($FR, "Line2". " \ n "); fwrite($FR, "Line3". " \ n "); fclose($FR); //Close Document?>

About open Mode

R read-only-read mode, open file, start reading from file header
r+ read-write to open the file, read and write from the file header
W write-write to open the file, while emptying the contents of the file, the file pointer point to the beginning of the file. If the file already exists, the existing content of the file is deleted, and if the file does not exist, the file is created
w+ can open the file in a readable and writable manner while emptying the contents of the file and pointing the file pointer at the beginning of the file. If the file does not exist, the file is created
A append opens the file in write-only mode, pointing the file pointer at the end of the file. If the file does not exist, the file is created
A + is followed by a readable and writable way to open the file, pointing the file pointer at the end of the file. If the file does not exist, the file is created
b binary is used to connect to other modes. It is recommended to use this option for a greater degree of portability

PHP txt operation, adding the class capacity

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.