Home > Backend Development > PHP Tutorial > textarea里面的换行如何解决

textarea里面的换行如何解决

WBOY
Release: 2016-06-13 10:12:06
Original
1068 people have browsed it

textarea里面的换行怎么解决?
要在textarea里面解决换行问题怎么处理?

不是特别的想用编辑器去做这个,因为这个文本是用户自主输入提交的,所以从安全角度来考虑觉得只在textarea里面能让他换行就行了。

另外如果实在解决不了用编辑器去做的话,我前台已经把所有的用户自主输入的POST给htmlentities掉了。那么那些标签又是怎么实现的呢?

求经验大牛给个解决方案。。

------解决方案--------------------
用程序将\n\r 换成

------解决方案--------------------
$content = "test\nxxx\ntest\n";
$content=nl2br($content);
echo $content;

------解决方案--------------------
将$_POST['content']用htmlspecialchars转换:
$new = htmlspecialchars("Test", ENT_QUOTES);
echo $new; // Test

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template