Home  >  Article  >  Backend Development  >  Line break problem in php

Line break problem in php

巴扎黑
巴扎黑Original
2016-11-23 13:33:011240browse

A brief discussion on the problem of line breaks in PHP

1.echo "n"; is just escaped, which is equivalent to a space, but there is no line break, but it is broken in the source file. (Explanation from netizens: n is ASCII code, and the browser parses HTML code, not ASCII code)

2.echo "rn"; After debugging, the result is the same as 1.

3 .echo nl2br("n"); can achieve line breaks. The nl2br() function inserts an HTML newline character (
) before each new line (n) in the string.

Code: echo

Output: line1.

line2

htnl code: line1


line2

4.echo ( "$str
");echo ("$str
");echo "
";echo "
" The four writing methods can achieve line breaks.

5.
$str="line1nline2";

$str1='line1nlin2';

$str3='lins1rnlin2';

echo $str;

echo $str1;

echo $str2;

echo $str3;

?> line2

line1nlin2

line1rnlin2

line1

line2

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