If PHP Code is selected then the raw PHP code will be shown and editable. I played around with this a little the other day using htmlspecialchars_encode and htmlspecialchars_decode with $_POST and everything seems fine when using PHP Code editor.
If there is something open source already out there already, it could save me from developing the whole thing from scratch.
Thank you in advance.
Try adding this to your TinyMCE configuration:
protect: [ /<\?php.*?\?>/g // Protect php code ],