Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的网站中,我希望用户写下他们的评论。但是当他们在文本字段中按下“输入”时,我想将此评论作为新段落保存到 mysql。我想用段落从mysql中获取这个评论。
我用谷歌搜索了很多人建议“nl2br()”,但我不明白我是如何使用它的。我怎样才能使它成为可能?谢谢...
新行会自动保存为 mysql 中的新行,无需为此做任何特别的事情。
但是,当您将新行输出到 html 时,它们将显示为空格(通常...),因此当您输出到 html 时,您必须使用nl2br()以便在<br>每个新行中添加一个标签。
nl2br()
<br>
<?php echo nl2br($comment); ?>
http://php.net/manual/en/function.nl2br.php