Title: Php code displaying in the output.
Last modified: August 21, 2016

---

# Php code displaying in the output.

 *  Resolved [nvijaya](https://wordpress.org/support/users/nvijaya/)
 * (@nvijaya)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-code-displaying-in-the-output/)
 * 1. First of all, want to thank for giving such wonderful plugin.
    For me every
   thing worked fine except some issues.
 * 2. The set of i used in between [insert_php] and [/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><br />";
       }
       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."<br />";
       }
       foreach ( $contact as $key4 => $value ) {
       if($key == $key1 && $key1 == $key2 && $key2 == $key3 && $key3 == $key4){
       echo "<span style='font-weight:lighter;'>Direct:</span>"." ".$value."</span><br /><br /><br /><br /><br /><br />";
       }
       }
       }
       }
       }
       }
       [/insert_php]
       </p>
       <div class="clear"></div>
       ```
   
 * 3. I am getting the correct output, but, at the end of the output i am getting
   php code also.Please help me out to solve this issue.
 * [http://wordpress.org/plugins/insert-php/](http://wordpress.org/plugins/insert-php/)

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

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-code-displaying-in-the-output/#post-4087950)
 * nvijaya, the PHP code runs with errors.
 * The PHP code used with Insert PHP needs to be able to run independently before
   it will run without errors within Insert PHP.
 * If you put this into a file named test.php
 *     ```
       <?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><br />";
       }
       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."<br />";
       }
       foreach ( $contact as $key4 => $value ) {
       if($key == $key1 && $key1 == $key2 && $key2 == $key3 && $key3 == $key4){
       echo "<span style='font-weight:lighter;'>Direct:</span>"." ".$value."</span><br /><br /><br /><br /><br /><br />";
       }
       }
       }
       }
       }
       }
       ?>
       ```
   
 * Then load test.php to your server and type its URL into your browser. You’ll 
   see what I mean.
 * The error I noticed immediately is the code between the [insert_php][/insert_php]
   tags calls a function get_post_custom_values(). Yet, there is no such function
   available in the code between the [insert_php][/insert_php] tags.
 * I think get_post_custom_values() is a WordPress function. Unfortunately, WordPress
   functions aren’t available to PHP code between the [insert_php][/insert_php] 
   tags.
 * Intuitively, a person could think WordPress functions would be available for 
   use here as they are available for use in WordPress plugins. But that’s not the
   case. The code between [insert_php][/insert_php] tags is never made a part of
   the plugin. Instead, Insert PHP runs the code within an eval() statement.
 * Once your PHP code runs independently on a page by itself, then it can be used
   with Insert PHP.
 * Will
 *  Thread Starter [nvijaya](https://wordpress.org/support/users/nvijaya/)
 * (@nvijaya)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-code-displaying-in-the-output/#post-4087962)
 * 1. Thanks a lot for your immediate response.Yes, your right “get_post_custom_values()”
   is a wordpress function.And, also i tried to run the code independently,but, 
   it won’t.
 * 2. So, i tried to get the value through “Post” method of php.Now, everything 
   works fine.
 * 3.Once again want to mention, very nice and compatable plugin.
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-code-displaying-in-the-output/#post-4087966)
 * You’re welcome, nvijaya. And thank you for your kind words.
 * Will

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

The topic ‘Php code displaying in the output.’ 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: [12 years, 9 months ago](https://wordpress.org/support/topic/php-code-displaying-in-the-output/#post-4087966)
 * Status: resolved