Note: When the front page is displayed, use nl2br to change the line break to The second example: I found an interesting thing:
Normally, the above The code should replace newlines, but it doesn't. Very frustrated, tried many times, but it just doesn't work. Finally changed it to this:
and it works. It turns out to be a problem with double quotes and single quotes! Double quotation marks are less efficient than single quotation marks, because during the process of parsing double quotation marks by PHP, it will also judge whether there are variables inside, but single quotation marks will not make this judgment, so generally speaking, variables are not involved. I always use single quotes, but I didn’t expect that replacing the newline character this time would not work using single quotes... Finally written as:
so you can replace the newlines. Isn't it very convenient? >>>> Articles you may be interested in: php remove string newline character instance analysis php compress html (clear newlines, clear tabs, remove comment marks) How to convert textarea line breaks in php forms Code examples of php regular filtering html tags, spaces, newlines, etc. Summary of how to remove line breaks in php How to compress html webpage code with php (remove spaces, newlines, tabs, comment marks, etc.) php generates excel and controls line breaks in Excel cells |