Home > Backend Development > PHP Tutorial > 深入PHP nl2br()格式化输出的详解_php技巧

深入PHP nl2br()格式化输出的详解_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 09:03:24
Original
1120 people have browsed it

nl2br()函数可将字符串中的换行符转成HTML的换行符号

复制代码 代码如下:

$str = "最近几天一直在下雨,难过死了
,球也打不成,鞋子也湿透了。";
echo $str;
echo "
";
echo nl2br($str);
?>

输出结果:
复制代码 代码如下:

最近几天一直在下雨,难过死了,球也打不成,鞋子也湿透了。
最近几天一直在下雨,难过死了,球也打不成,鞋子也湿透了。

附:深入探讨"
"和"\r\n"两者有什么区别??
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template