PHP file php7php environment build php from entry to proficient

Source: Internet
Author: User
Php: PHP files: common methods for operating files: flie_put_contents (url, str); file_get_contents (url); file_put_contents ($ path, $ str); echofile_get_contents ($ path ); echo; file_put_conten

Common methods for file operations

Flie_put_contents (url, str );
File_get_contents (url );


  

When the file size is too large, you cannot use the above method to perform one-time operations on the above content. use the following function to solve the problem:

  • Fopen () open the file handle (the data stream channel between php and files)
    Parameter 1: file address
    Parameter 2: How to open the file. you can restrict the operation to be completed after opening the file.
    File mode:
    R (read) read mode
    W (write) replaces the write mode and clears the file content. if the file does not exist, it is created.
    A (append)
    X replaces the write mode, clears the file content, and does not exist.
    + Expansion
    R + read/write mode: place the file pointer in the file header
    W + read/write mode, clear the file, put the file pointer in the file header
    X + read/write mode: clears the file, places the file pointer in the file header, and does not automatically create the file
    In a + read append write mode, write operations are always at the end, and read operations are limited by file pointers.
    When both read and write operations can be performed, the difference is the file initialization.

  • Continuous read:
    Fread (file handle [, length]); read the content of the specified length (bytes)
    Fgets (file handle [, length]); reads the content of the specified length (bytes)
    Length: refers to the read length-1 byte
    The end of the row is the function termination operation.
    Fgetc (file handle) reads one byte at a time

  • Fwrite (file handle, content );

  • Fclose (file handle );
  • Ftell (); find the pointer position
  • Fseek (); position of the pointer

R + read/write is affected by the pointer, and the original pointer content is replaced by the write
W + clear content
A | a + pointer has uncertainties. Read is affected by the pointer and write is appended.

  • Last modification time of filemtime (url) file
  • Filesize () file size

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces the PHP file, including the php content, and hopes to help those who are interested in the PHP Tutorial.

    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.