php存储富文本编辑器内容到数据库

 富文本编辑器内容会包含很多字符(如: ",',<,>),所以我们在存取的时候必须将他们转义.

存入

/*把预定义的字符 "<" (小于)和 ">" (大于)转换为 HTML 实体:
例:  转换前:  $str = "This is some <b>bold</b> text.";
             echo htmlspecialchars($str);
    转换后:  This is some &lt;b&gt;bold&lt;/b&gt; text.
*/
内置函数:  htmlspecialchars()

取出

/*把 HTML 实体转换为字符:
例:  转换前:  $str = "&lt;&copy; W3CS&ccedil;h&deg;&deg;&brvbar;&sect;&gt;";
			 echo html_entity_decode($str);
	转换后:  <© W3CSçh°°¦§>		 
*/
内置函数:  html_entity_decode()

作者在用的富文本编辑器 HandyEditor

猜你喜欢

转载自blog.csdn.net/qq_42961790/article/details/107279685