(Lone solitary Nine swords)--php Video Learning--File system

Source: Internet
Author: User
Tags fread

"One" File system overview

File creation, deletion, editing, copying, pasting (moving), i.e. file additions and deletions

"Two" read the file

Open read: ReadFile (String), passing in the file path to open the read (if read succeeds, the number of bytes returned)

Open assignment to Variable: file_get_contents (), return character type

Open Read Close step: fopen,fread,fclose

①fopen has two parameters, fopen (open path, open mode), open as read/write only

②fread has two parameters, fread (read file name, optional, read maximum byte limit)

③fclose close files to prevent open files from occupying server resources

fopen Open File Mode list:

R Read-only , pointing the file pointer to the file header;

r+ Reading and writing , pointing the file pointer to the file header;

W writes Open , points the file pointer to the file header and intercepts the file size to 0. Create a file if the file does not exist

w+ Read-write mode opens , pointing the file pointer to the file header and intercepting the file size to 0. Create a file if the file does not exist

A write mode opens , pointing the file pointer to the end of the file. Create a file if the file does not exist

A + read-write mode opens , pointing the file pointer to the end of the file. Create a file if the file does not exist

X is created and opened in write mode . If it already exists, the fopen () call fails to return false and generates an error message with a e_warning warning level. If the file does not exist, try to create

X+ is created and opened as read-write . ...

"Three" Create modified file contents

(1) Get the contents of the file

File_get_contents return string
$contents = file_get_contents ('./new.txt'"$contents  ";

(2) write the contents of the file

   file_put_contents return byte length

Writes a string to the specified file, creates a file if it does not exist, and returns the length of bytes written

$contents = file_put_contents ('./new1.txt',' I'm new content '   "$contents";

(3)

(Lone solitary Nine swords)--php Video Learning--File system

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.