我以某种方式将数据存储到数据库中。例如 - 使用输入,空格。并且它以相同的方式成功存储,但是当我输出那些存储的数据时,它只是以单行显示。它没有考虑任何空白区域或进入我所做的。我想以相同的方式显示数据。
答案 0 :(得分:1)
在打印MySQL数据时在PHP中使用nl2br()
函数。
echo nl2br($row["column"]);
或者,如果您需要显示它们的存储方式,则需要使用<pre>
标记,或者可以将显示对象的CSS设置为:
white-space: pre-wrap;
考虑这样的文字:
I have a big house!
And there's a line before this line!
Also I have left a huge space!
上面的全文将显示在<div>
中,如下所示:
我有一个大房子!
这条线前面有一条线! 我也留下了一个巨大的空间!
div {white-space: pre-wrap; font-family: 'Segoe UI', Tahoma, sans-serif;}
&#13;
<div>
I have a big house!
And there's a line before this line!
Also I have left a huge space!
</div>
&#13;
答案 1 :(得分:0)
CRLF不会被视为HTML中的换行符。
示例:
<pre>
your data field bound variable name here
that has
line feed and carriage return
as part of it's content
</pre>