Recently write PHP code to read text lines from a text file (text file is the ANSI character set)
PHP 2 built-in functions file and fgets can implement this function
file-to read an entire file into an array
fgets-reading a line from the file pointer
Common denominator: Each text line at the end of both reads contains a newline character (reads text using the ANSI character set, each of which takes one byte, and if the text file is converted to the Utf-8 character set, the result is different, not tested);
Different points: The above is a newline character to \ n input, if the line feed is \ r \ n Input, then file will read into the \r\n,fgets will be processed off \ r reserved \n,\r and \ n with the Ord () function shows the ASCII value is 13 and 10 respectively.
All of these use ANSI character set text tests.
When using fwrite () to write to a text file There is a strange phenomenon, fopen () with ' wt ' Open, write "\ r \ n", with the 16 binary editor to open the text file will find that the line code is CR CR LF (\r\r\n), and the ' W ' mode to open the normal "\ r \ n".