What to do if php r n does not wrap?

藏色散人
Release: 2023-03-08 13:18:02
Original
2911 people have browsed it

php The solution for r n not to wrap: First open the PHP file where r n does not wrap; then change the single quotes in the output code to double quotes to achieve normal line wrapping.

What to do if php r n does not wrap?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

\nNewline in php string The solution to the problem of invalid characters and unable to wrap lines

For example, the following code:

The code is as follows:

<?php
echo &#39;hello\n&#39;;
echo &#39;world&#39;;
?>
Copy after login

The newline character \n in the program will be output directly, The line break cannot be correct. The solution is to change the single quotes to double quotes:

The code is as follows:

<?php
echo "hello\n";
echo "world";
?>
Copy after login

That’s it! In fact, it is the difference between double quotes and single quotes in PHP. In a simple summary, variables in double quotes can be parsed, and single quotes are absolute strings.

[Recommended study: "PHP Video Tutorial"]

Note:

php Line breaks in different systems

Among different systems The implementation of line breaks is different

/n is used in linux and unix

MAC uses /r

window In order to reflect the difference from linux, it is /r/n

So the implementation methods are different on different platforms

The above is the detailed content of What to do if php r n does not wrap?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template