PHP和Mysqli如何回声换行 [英] Php and Mysqli how to echo break of line

查看:59
本文介绍了PHP和Mysqli如何回声换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我用php保存了部分文本(带有换行符),例如:

Hi guys when I save with php some part of text (with break of lines) for example:

this is 

an example

在我的数据库中,我看起来就像写了它

in my database I see like I wrote it

但是当我从数据库中回显这些数据时,我发现它是错误的

But when I echo this data from my database I see it wrong

你能帮我吗?

我的代码是这个

echo '<p class="date">' . $date . "</p>";
echo '<p class="post">' . $posts . "</p>";

推荐答案

,您可以检查nl2br函数( http://php. net/nl2br )

you can check nl2br function (http://php.net/nl2br)

echo '<p class="date">' . $date . "</p>";
echo '<p class="post">' . nl2br($posts) . "</p>";

这篇关于PHP和Mysqli如何回声换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆