PHP Read file function fread,fgets,fgetc,file_get_contents and use summary

Source: Internet
Author: User
Tags fread php read file

The Fread (), fgets (), fgetc (), file_get_contents (), and file () functions are used to read content from a file.

  Fread ()

The Fread () function is used to read the file (it can be used safely in binary files)

Syntax: string fread (int handle,int length)

  Fread () reads up to length bytes from a file pointer handle. Stops reading a file when any of the following conditions are encountered

    • When the maximum length of bytes is read

    • When the end of the file is reached (EOF)

    • (for network streams) when a package is available

    • or (after opening the user space stream) 8,192 bytes have been read. For example: Read 10 bytes from the file Test.txt.

      <?php    $filename = "test.txt";    $fh = fopen ($filename, "R");    Echo fread ($FH, "ten");    Fclose ($FH);? >

        

PHP Read file function fread,fgets,fgetc,file_get_contents and use summary

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.