In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the differences between fgetc () and fgets () in php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Differences: 1. Fgetc () is used to read a character from an open file and return a string containing one character, while fgets () is used to read a line of data from an open file and return a string of specified length. 2. The fgetc () function accepts only one argument, while the fgets () function accepts two arguments.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, both fgetc () and fgets () can read data from a file, but there are differences, which are described below.
The difference between php fgetc () and fgets ()
1. Functional differences
Fgetc (): reads a character from an open file
Fgets (): reads a row of data from an open file
2. Grammatical differences
Fgetc (): only one parameter is accepted
Fgetc ($handle)
The parameter $handle is the open file
Fgets (): two parameters are acceptable
Fgets ($handle [, $length])
The parameter $handle is the open file
The parameter $length is optional and is used to set the length of data to be read.
3. The difference of return value
The fgetc () function returns a string containing a character that is obtained from the file pointed to by $handle. Returns FALSE when EOF is encountered.
The fgets () function reads a line from a specified file and returns a string of a specified length. Stop when you encounter a newline character, EOF, or read the $length-1 byte. If the $length parameter is omitted, the length of 1k (1024 bytes) is read by default.
Expand knowledge:
We have a text file called "test.txt" that contains:
Use fgetc () to read the file character by character
Use fgets () to read the file line by line
This is the end of the content of "what is the difference between fgetc () and fgets () in php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.