Home  >  Article  >  Backend Development  >  请教一下关于 textarea 换行 的问题

请教一下关于 textarea 换行 的问题

WBOY
WBOYOriginal
2016-06-23 13:57:32754browse


在HTML上是 textarea 里面输入内容加回车换行再输入内容。。。
然后POST到PHP页面,把数据保存在数据库字段里面,类型为 text
接着在前端显示的时候,没有换行效果,如何解决,谢谢。

如果在textarea里显示是有换行 效果的。


回复讨论(解决方案)

'在前端显示的时候' 是指在textarea里面还是在外面?

内容

你不知道文本换行和HTML换行是不一样的吗?
该好好学习了

显示的时候,用nl2br 方法把换行转成html的换行标记
便可。

例如:

<?php$content = <<<TXTaaaabbbbccccddddTXT;echo nl2br($content);?>

贴出你在text显示的数据?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn