Title: embedded php code breaks
Last modified: August 22, 2016

---

# embedded php code breaks

 *  Resolved [denisseattle](https://wordpress.org/support/users/denisseattle/)
 * (@denisseattle)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/embedded-php-code-breaks/)
 * [https://wordpress.org/support/topic/converts-to?replies=4](https://wordpress.org/support/topic/converts-to?replies=4)
 * So embedding $function()->$variable becomes $function()->$variable and PHP throws
   a visible error in the browser.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/embedded-php-code-breaks/#post-5378359)
 * The only way I’ve been able to duplicate the issue is with these two steps:
 * 1.
    Paste the PHP code into the post or page with the Text tab, not the Visual
   tab. This tells WordPress to save the code as is, not to convert special characters
   into HTML entities.
 * 2.
    Then, use the Visual tab to make an edit. When the visual tab is used, WordPress
   does convert special characters into HTML entities. And this includes the PHP
   code that was earlier pasted in with the Text tab.
 * I’ve been wracking my brain trying to come up with a solution that prevents WordPress
   from converting special characters between the [insert_php]…[/insert_php] tags.
   It’s software, so there’s gotta be a way. I just need to figure it out.
 * Will
 *  Thread Starter [denisseattle](https://wordpress.org/support/users/denisseattle/)
 * (@denisseattle)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/embedded-php-code-breaks/#post-5378382)
 * Yes, when Visual opens by default, the brackets in php are altered before you
   can switch to Text. Your plugin allows some php syntax to be inserted, but not
   all.
 * The Visual editor leaves html tags but changes other brackets. Maybe it could
   be amended to classify certain strings, ->, like html tags?
 * Incorporate an option to force WP to open by default in Text, or certain pages
   as Text?
 * Copy code when a page is opened for editing, and add a “fix” button to paste 
   it back unaltered?
 * Recommend an alternative visual editor that behaves better?
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/embedded-php-code-breaks/#post-5378383)
 * Ah, thanks for those suggestions. It gave me an idea.
 * I don’t have access to the Visual editor.
 * Would you test something for me, please?
 * Let’s try this:
 *     ```
       <insert_php
       echo (1<2) ? 'yes' : 'no';
       >
       ```
   
 * And also this:
 *     ```
       <insert_php
       code="
       echo (1<2) ? 'yes' : 'no';
       ">
       ```
   
 * It’s not code that will run, just a test of character conversion.
 * If the Visual editor will leave either of those less-than angle brackets as a
   character instead of converting it into an HTML entity, then I have something
   I may be able to work with.
 * Thank you!
 * Will

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘embedded php code breaks’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/embedded-php-code-breaks/#post-5378383)
 * Status: resolved