Title: Displays PHP Code
Last modified: August 20, 2016

---

# Displays PHP Code

 *  Resolved [JDDunn9](https://wordpress.org/support/users/jddunn9/)
 * (@jddunn9)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/displays-php-code/)
 * I have a script that uses a GET variable. If there is no GET variable ( mysite.
   com/widget/ ) it displays what I would expect. If I do use it though, ( mysite.
   com/widget/?id=5 ) then it displays all the PHP code, including the [insert_php]
   parts. It also works fine if I use a made up GET name like mysite.com/widget/?
   madup=5.
 * I put the code in the HTML section of the page, not the View part, and the PHP
   code works fine if I put it in it’s own file and execute it. Any idea what could
   be wrong?
 * [http://wordpress.org/extend/plugins/insert-php/](http://wordpress.org/extend/plugins/insert-php/)

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

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/displays-php-code/#post-3296984)
 * JDDunn9, post the code you are testing with. I’ll try to duplicate the issue.
 * Will
 *  Thread Starter [JDDunn9](https://wordpress.org/support/users/jddunn9/)
 * (@jddunn9)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/displays-php-code/#post-3296987)
 * After further testing, it looks like it wasn’t the GET variable, it was the code
   executed if it was set. It looks like the code breaks if you try to use the increment
   operator “++”. For example, this code also breaks on me.
 * $i = 0;
    $i++;
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/displays-php-code/#post-3296988)
 * Insert PHP uses the eval() function to run the PHP code between [insert_php] 
   tags.
 * When eval() runs, the code is subject to the environment it is running in, the
   rest of the WP code used to process the page. Which may be why the $_GET[‘id’]
   was misbehaving earlier. Don’t know without seeing the code you were using. I
   think id is used to determine which post to publish.
 * I don’t know why $i is misbehaving. $ti works fine.
 *     ```
       [insert_php]
       $ti=0;
       $ti++;
       echo $ti;
       [/insert_php]
       ```
   
 * Suggest trying a different variable name when the current one behaves different
   than expected.
 * Will
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/displays-php-code/#post-3297025)
 * Gratuitous content so the system will accept the “resolved” checkbox.
 *  [nvijaya](https://wordpress.org/support/users/nvijaya/)
 * (@nvijaya)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/displays-php-code/#post-3297026)
 * 1. When i put my set of codes inbetween [insert_php][/insert_php]:
    <p align=”
   left”> [insert_php] $name = get_post_custom_values(‘staff_name’); $image = get_post_custom_values(‘
   staff_image’); $info = get_post_custom_values(‘staff_info’); $email = get_post_custom_values(‘
   staff_email’); $contact = get_post_custom_values(‘staff_contact’); foreach ( 
   $image as $key => $value ) { echo $value; foreach ( $name as $key1 => $value ){
   if($key == $key1){ echo “<span class=’staff_name’>”.$value.” “.”| </span>”; }
   foreach ( $info as $key2 => $value ) { if($key == $key1 && $key1 == $key2){ echo“
   <span class=’staff_info’>”.” “.$value.”</span>“; } foreach ( $email as $key3 
   => $value ) { if($key == $key1 && $key1 == $key2 && $key2 == $key3){ echo “<span
   class=’staff_detail’><span style=’font-weight:lighter;’>Email:</span>”.” “.$value.”“;}
   foreach ( $contact as $key4 => $value ) { if($key == $key1 && $key1 == $key2 &&
   $key2 == $key3 && $key3 == $key4){ echo “<span style=’font-weight:lighter;’>Direct:
   </span>”.” “.$value.”</span>
 * “;
    } } } } } } [/insert_php] </p> <div class=”clear”></div>
 * 2. My output is coming correctly.But, the problem is along with my output, some
   codes are also displaying at the end.

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

The topic ‘Displays PHP Code’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3475630)
 * [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/)

 * 5 replies
 * 3 participants
 * Last reply from: [nvijaya](https://wordpress.org/support/users/nvijaya/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/displays-php-code/#post-3297026)
 * Status: resolved