Home > Backend Development > PHP Tutorial > 百度编辑器提交数据时如何防止html标签被转义

百度编辑器提交数据时如何防止html标签被转义

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-20 12:38:31
Original
1591 people have browsed it

现在正在用ThinkPHP进行开发,用百度编辑器向phpmyadmin提交文本内容后原来的数据格式标签已被转义,在数据库中显示如:


在前端调用数据库后浏览器解析为

    无法显示原来的格式。
请问各位有没有什么比较好的解决办法?如何防止在表单提交时html标签被转义?谢谢!


回复讨论(解决方案)

$str = "<p>    ";$html = htmlspecialchars_decode($str);var_dump($html);
Copy after login

数据库取出来在转一次就ok了

百度编辑器示例的服务器端代码是

//获取数据$content =  htmlspecialchars(stripslashes($_POST['myEditor']));
Copy after login

你照抄的话当然会被转义!
$content = stripslashes($_POST['myEditor']);
就不转义了

老徐好勤快,赞!

我用的就是

htmlspecialchars_decode
Copy after login

onmouseenter


百度编辑器提交数据时如何防止html标签被转义


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