加载 PHP 到 TinyMCE

Load PHP Into TinyMCE

如何加载 PHP 到 TinyMCE 我有内容 :

<?php echo "OK"; ?>

图片:http://i.stack.imgur.com/pqbkq.png

我想把它放到文本区域(TinyMCE)。我尝试了很多方法但没有用。 请帮我。谢谢。

<textarea id="TinyMCE1" name="TinyMCE1" rows="15" cols="80">
     <?php echo htmlentities("&lt;?php echo 'OK'; ?&gt;"); ?>
</textarea>

如果您希望能够将 PHP 放入 TinyMCE 的源视图中并让 TinyMCE 保留 PHP 标签,您可以使用 TinyMCE 配置的保护属性:

protect: [
    /<\?php[\s\S]*?\?>/g // Protect php code
],

来自文档:

"This configuration option enables you to control what contents should be protected from editing while it gets passed into the editor. This could, for example, be control codes in the HTML. It's recommended not to use inline control contents since it breaks the WYSIWYG editing concept, but sometimes they can't be avoided.

The option takes an array of regular expression that it will match the contents against and these will be invisible while editing."