When using the phpfwrite () function, many new users will encounter the most common but necessary solution, that is, line feed writing. We all know the linefeed of php: \ n, carriage return: \ r. when we need to change the line, we usually use the "\ r \ n" combination. But why \ n linefeed does not work when we use fwrite to write a file. This article will show you how many new users encounter the most common but necessary problem when using the php fwrite () function when the phpfwrite () function is written in line breaks, that is, line feed writing. We all know the linefeed of php: \ n, carriage return: \ r. when we need to change the line, we usually use the "\ r \ n" combination. However
Why \ n linefeed does not work when we use fwrite to write a file. This article will show you howPhp fwrite () function does not work when line feed is written
Let's take a look at the following example:
In this example, we have used a carriage return line break, but we found that when the File.txt file is opened, there is no carriage return line break effect.
Why? The carriage return line break "\ r \ n" is not parsed as a line break, but is directly output as a character.
Why is this problem solved?
It is actually a single double quotation mark! We can replace the single quotation mark "'" of the $ word string with the double quotation mark. The correct syntax is as follows:
Now, open the File.txt file and check it out:
It is found that there is no problem with line breaks.
[Recommended articles ]:
Example Description: php fwrite () function appending and line feed writing
The above is the details about what to do when the php fwrite () function does not work when it is written into the line feed. For more information, see other related articles in the first PHP community!