Phpfgets function _ PHP Tutorial

Source: Internet
Author: User
Phpfgets function. Phpfgets function fgets (in PHP4, in PHP5) fgets-get the line from the file pointer description string fgets (resource $ processing [Summary $ length]) to get the line from the file pointer. Parameter handle php fgets function

Fgets
(PHP 4 and PHP 5)

Fgets-get the pointer to the line slave file

Description
String fgets (resource $ processing [Summary $ length])
Get the line from file pointer.

Parameters

Handle
The file pointer must be valid and must point to a file that successfully opens fopen () or fsockopen () (and has not closed fclose ()).

Length
The end length of the read period is-1 byte. if it is read, the line feed (included in the returned value), or the EOF analysis (whichever comes first) is used ). If no length is specified, the stream continues to be read until the end of the row is reached.

Note: If PHP 4.3.0 is earlier than 1024, the line length will be assumed. If most of the files are larger than 8 kB, more effective resources will specify the maximum row length for your scripts.



Return value
Returns a string with a maximum length of-1 bytes to read the file, indicated by processing.

If an error occurs, FALSE is returned.

Modify

Version description
4.3.0 fgets () is currently binary secure
4.2.0 length parameters are optional

Check instances:

$ Handle = @ fopen ("/tmp/inputfile.txt", "r ");
If ($ handle ){
While (! Feof ($ handle )){
$ Buffer = fgets ($ handle, 4096 );
Echo $ buffer;
}
Fclose ($ handle );
}
?>


Http://www.bkjia.com/PHPjc/445477.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445477.htmlTechArticlephp fgets function fgets (PHP 4, PHP 5) fgets-get line from file pointer description string fgets (resource $ handle [Summary $ length]) get line from file pointer. Parameter handle...

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.