In the PHP language, there are many powerful functions that support the continuous development of this language, allowing more and more programmers to choose to use this language. PHP Functionfgets is one of the powerful functions.
PHP function fgets -- Read a line of instructions from the file pointer, the syntax is as follows
fgets ( handle ,length )
Detailed explanation of parameters:
Description | |
---|---|
Required. Specifies the file to be read. | |
Optional. Specifies the number of bytes to read. The default is 1024 bytes. |
##
< ?php $handle = fopen("/tmp/test.txt", "r"); while (!feof($handle)) { $buffer = fgets($fd, 4096); echo $buffer; } fclose($handle); ?>
used for binary files. Earlier versions did not.
Note: If you encounter that the PHP function fgets cannot recognize the line ending characters of Macintosh files when reading files, you can activate the auto_detect_line_endings runtime configuration option.
The above is the detailed content of Detailed explanation of how to use PHP built-in function fgets() to read pointer files. For more information, please follow other related articles on the PHP Chinese website!