What should I do if the line break does not work when the phpfwrite () function is written in a line break?

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.