Home >Backend Development >PHP Problem >What to do if php r n does not wrap?

What to do if php r n does not wrap?

藏色散人
藏色散人Original
2021-03-05 09:59:302932browse

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;;
?>

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";
?>

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!

Statement:
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
Previous article:How to remove r n in phpNext article:How to remove r n in php