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 );
}
?>