如何正确显示具有HTML格式和文本格式的数据库中的文本 [英] How to correctly display text from db which has HTML formatting and text formatting
本文介绍了如何正确显示具有HTML格式和文本格式的数据库中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< p>
等等等等
等等
< / p>
当我从db中获取文本并显示它时,我可以获取来创建段落空间,但是blah之间的段落不会显示出来。
当我尝试使它一起工作时,我最终会在按下enter键后出现新的行,并从< p>
>中添加新行。
有没有一种方法可以确保两种格式化的方式很好地协同工作?
<您可以使用:
$ p $
echo nl2br($ db_string)解决方案
;
I have text in db which looks like this:
<p>
blah blah
blah
</p>
When I get the text out of db and display it, I am able to get the <p></p>
to make the paragraph space, but the paragraph between the lines of blah does not show up.
When I try to make it work together, I end up with new lines after the natural new line from pressing the enter, and new line from <p>
so I end up with way too much space between paragraphs.
Is there a way to make sure both ways of formatting work together nicely?
解决方案
You can use :
echo nl2br($db_string);
这篇关于如何正确显示具有HTML格式和文本格式的数据库中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文