我在html中有一个textarea,可以使用PHP保存到mysql表中。用户在此文本区域中写的内容可能如下所示

1. Follow this directions

    First buy some wood, then get a hammer.

2. Blah blah


因此,当它保存到数据库中时,它只是保存了..问题是当我检索此数据时,它看起来像这样(我将其放在<p> </p>

1. Follow this directions First buy some wood, then get a hammer. 2. Blah blah


但我不想这样显示,我想保留用户输入它的方式..我该怎么做?

谢谢

最佳答案

换行符应存储在mysql中-您可以将其包装在<pre></pre>标记中,该标记将告诉浏览器文本是预先格式化的。然后停止导致您的问题的html空格清洗

关于php - 检索数据时如何保留空间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8161795/

10-12 12:51
查看更多