How to use fgets function in php
This article mainly explains "how to use the fgets function in php". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the fgets function in php.
In php, the fgets function is used to read a line of a specified file and return the read result, which ends reading when it reaches the specified length, encounters a newline character, or reads to the end of the file. The result of failure is false with syntax of "fgets (file,length)".
Operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer
What is the usage of fgets function in php
The fgets () function returns a line from the open file.
The fgets () function stops returning a new line when it reaches the specified length (length-1), encounters a newline character, and reads to the end of the file (EOF), whichever comes first.
This function returns FALSE if it fails.
The syntax is:
Fgets (file,length)
Where file is required to specify the file to be read, and length is optional to specify the number of bytes to be read. The default is 1024 bytes.
Examples are as follows:
Or
Thank you for your reading, the above is the content of "how to use the fgets function in php". After the study of this article, I believe you have a deeper understanding of how to use the fgets function in php, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!