Home  >  Article  >  php教程  >  深入PHP nl2br()格式化输出的详解

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

WBOY
WBOYOriginal
2016-06-13 11:51:301166browse

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

复制代码 代码如下:


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


输出结果:

复制代码 代码如下:


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


附:深入探讨"
"和"\r\n"两者有什么区别??
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