PHP writes strings to the txt file, which causes line breaks.
$ DOCUMENTROOT = $ _ SERVER ['document _ root']; $ file = fopen ("$ DOCUMENTROOT/php_02/123.txt"," wb "); fwrite ($ file, "line 1 ". "\ n ". "line 2 n line 3"); fclose ($ file );
This is useless.
However
$ DOCUMENTROOT = $ _ SERVER ['document _ root']; $ file = fopen ("$ DOCUMENTROOT/php_02/123.txt"," wb "); fwrite ($ file, "line 1 ". "\ r \ n ". "line 2 n line 3"); fclose ($ file );
This is the case. ask why.
Reply to discussion (solution)
Different editors have different resolution effects.
Open the following two programs in the command line, and then use the program to open the generated file, you can see how the program parses \ n.
Notepad
Wordpad
In Windows, many editors wrap \ r \ n and ignore \ n.
You can enable the Word display control character function. \ n is the downward arrow and \ r \ n is the turning arrow.
Window \ r \ n
Linux \ n