PHP Learning Series 6

Source: Internet
Author: User
Tags rewind
PHP Learning Series Six

File operation:
fopen ();
fopen (Path,mode);
If you encounter problems with fopen opening remote files, check php.ini, which can be disabled by turning off the allow_url_fopen command in this file.
Fopen front with the @ symbol tells PHP to suppress all errors generated by the function call.
Fwrite () or fputs () can write files
Fwrite ($FP, $outputstring), a replacement function for the fwrite () function is file_put_contents ().
To close a file:
Fclose ($FP);
Read the file
Step: Open File--read file--close file.
fopen (file, ' RB ')
Feof () to determine the end of the file
Fgets (), FGETSS (), Fgetcsv ()
such as: er =fgets ($FP, 999): You can read a line of content from a file every time, until a newline character is read, or a file terminator, or a 998B read from a file. The maximum length that can be read is minus 1B for the specified length.
FGETSS () can filter the PHP and HTML tags contained in the string.
Fgetcsv ()

Read entire file: ReadFile (), Fpassthru (), file ()
Read one character: Fgetc ()
Reads one character at a time from a file.
Fread (): Read any length
Other useful file manipulation functions:
File_exists (): see if the file exists.
FileSize (): View the size of a file, returned in bytes.
NL2BR () converts the \ n character of the output to an HTML line break (
)
Unlink () deletes a file.
Rewind (), fseek () and Ftell ()
Rewind (): Resets the file pointer to the beginning of the file.
Ftell (): reports the position of the file pointer currently in the file, in bytes.
Fseek (Resource Fp,int offset[,int whence]), the fseek () function moves the file pointer fp from the hence location to offset bytes, and whence is an optional parameter whose default value Seek_ Set represents the beginning of the file.
Flock (): Locks the file, returns True if the lock is successful, or false if it fails
  • 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.