fgets

string fgets(resource file_handle, int bytes) 

Reads a line from a file.

Returns:

Current line; FALSE on error

Description:

fgets() is similar to fgetc() except that it returns a line of text from the file pointer of a length specified by the number of bytes. If a newline or EOF occurs before the number of bytes specified is read, fgets() returns the bytes read up to this point. This can be extremely useful when reading and processing lines of text from a file, pipe, or socket.

Warning:

Because some of the filesystem functions to read/write from files partially share the same code, one or more of the bugs reported elsewhere may also apply to this function.

3.0.6: Function not binary-safe.

3.0.11: Will not return when using non-blocking ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.