Home >Backend Development >PHP Tutorial >Line break problem in php
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