带'pre'标签和'nl2br'的双换行符 [英] Double line breaks with 'pre' tag and 'nl2br'
本文介绍了带'pre'标签和'nl2br'的双换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对pre
标签使用了nl2br
函数,但是遇到了一个奇怪的问题:有2个换行符,但是只有一个<br />
标签.
I used nl2br
function for pre
tags, but I've encountered a strange problem: there are 2 line breaks but there's only one <br />
tag.
例如:
code in line 1<br />
code in line 2<br />
显示为:
code in line 1
code in line 2
代替:
code in line 1
code in line 2
推荐答案
在<pre>
标记中换行将强制其显示为书面形式:包括空格,制表符和换行符.
因此,回车将创建新行,而<br />
将创建第二行.
Wrapping text in a <pre>
tag will force it to be displayed as written: including spaces, tabs and new lines.
Therefore the carriage return will create a new line AND the <br />
will create a second new line.
这篇关于带'pre'标签和'nl2br'的双换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文