PHP file php7 PHP Environment build PHP from beginner to proficient

Source: Internet
Author: User

Common ways to manipulate files

Flie_put_contents (URL,STR);
file_get_contents (URL);


   
    $str = time();$path = './time.txt';echo'';file_put_contents($path,$str);echo file_get_contents($path);echo'';file_put_contents($path,"\r".$str,FILE_APPEND);echo file_get_contents($path);

When the file is too large, you can not use the above method to operate the above content, using the following function to solve

    • fopen () Open file handle (data flow channel between PHP and file)
      Parameter 1: File address
      Parameter 2: Open mode, which action you want to complete after opening a file, can be restricted at the pattern location
      File mode:
      R (read) read mode
      W (write) replaces write mode, zeroing the contents of the file, creating
      A (Append)
      X replaces write mode, zeroing the contents of the file, does not exist without creating
      + Extended
      r+ read-write mode, place the file pointer over the file header
      w+ read-write mode, zeroing the file, placing the file pointer in the file header
      x+ read-write mode, zeroing files, placing file pointers on file headers, not creating files automatically
      A + read append write mode, the write operation is always at the end, the read operation is limited by the file pointer
      When both can read and write operations, the different is the initialization of the file

    • Continuous reads:
      Fread (file handle [, length]); Reads the contents of a specified length (bytes)
      Fgets (file handle [, length]); Reads the contents of a specified length (bytes)
      Length: Refers to the read length-1 bytes
      At the end of the line is the function's terminating operation
      FGETC (file handle) reads one byte at a time

    • Fwrite (file handle, content);

    • Fclose (file handle);
    • Ftell (); Finding the pointer position
    • Fseek (); Positioning pointer position

R+ reads and writes are affected by pointers, and writes replace the original pointer contents
w+ Empty Content
A | A + pointer has an indeterminate factor, reading is affected by a pointer, and writing is an append

    • Filemtime (URL) file Last modified
    • 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); }); });

    The above is the introduction of PHP files, including the content of PHP, I hope that the PHP tutorial interested in a friend helpful.

  • 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.