Daniel Valland
Daniel Valland

Reputation: 1107

Preventing browser from commenting out php code html text editor

I am using a html/javascript rich text area (CKeditor: http://ckeditor.com), that allows users to format text using html... One feature is to wrap currently selected text in a <code> tag. However, it seams that the browser is commenting out php code before the textarea is posted.

Example: I enter the php code snippet:

<?php
echo "hello";
?>

Click on wrap code: enter image description here

And expect as output:

<code>
<?php
echo "hello";
?>
</code>

However, what is inserted in the editor (by javascript) is:

<code><--?php echo "hello"; ?--></code>

Could this be a browser issue? (javascript causes the browser to render the html in the textarea of ckeditor, but the browser does not recognize the php tag?)

Upvotes: 1

Views: 370

Answers (1)

Dan
Dan

Reputation: 9478

According to the CK Editor Documentation you must have the Code Snippet plug in enabled:

The optional Code Snippet plugin allows you to insert rich code fragments and see a live preview with highlighted syntax. Its original implementation uses the highlight.js library, but the plugin exposes a convenient interface for hooking any other library, even a server-side one.

You should then include PHP as a supported language.

enter image description here

Here is a link to the code snippet add-on: http://ckeditor.com/addon/codesnippet

Upvotes: 1

Related Questions