2017-12-06 10:26
浏览 79

将PHP html字符串插入TinyMCE编辑器

Im trying to get HTML from my MySQL table inserted into my TinyMCE editor. But I have serious trouble setting up the PHP string into Javascript.

when I just try to insert it like this:

tinymce.activeEditor.setContent("'<? echo $description; ?>'", {format: 'raw'});

It has trouble with the single quotes and the double quotes in the $description variable. I get unidentified id's in my string because the string gets cut off due to the single and double quotes that are located in the string.

How can I insert this into TinyMCE, which ultimately comes down to how to make a HTML string without cutting of early?

图片转代码服务由CSDN问答提供 功能建议

我试图将我的MySQL表中的HTML插入到我的TinyMCE编辑器中。 但是我在将PHP字符串设置为Javascript时遇到了很大的麻烦。


  tinymce。  activeEditor.setContent(“'&lt;?echo $ description;?&gt;'”,{format:'raw'}); 

它有问题 单引号和$ description变量中的双引号。 我在我的字符串中得到了未识别的id,因为字符串因字符串中的单引号和双引号而被截断。

如何将其插入到TinyMCE中,最终归结为 如何在不削减早期的情况下制作HTML字符串?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douchen2011 2017-12-06 10:27

    You can simply replace those characters:

    tinymce.activeEditor.setContent("'<? echo str_replace(array('"', "'"), array('\"', "\'"), $description); ?>'", {format: 'raw'});
    解决 无用
    打赏 举报

相关推荐 更多相似问题