Php fgets function

Source: Internet
Author: User

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:

<? Php
$ Handle = @ fopen ("/tmp/inputfile.txt", "r ");
If ($ handle ){
While (! Feof ($ handle )){
$ Buffer = fgets ($ handle, 4096 );
Echo $ buffer;
    }
Fclose ($ 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.