Title: PHP code inside HTML blocks
Last modified: August 30, 2016

---

# PHP code inside HTML blocks

 *  Resolved [vlad13](https://wordpress.org/support/users/vlad13/)
 * (@vlad13)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/php-code-inside-html-blocks/)
 * Hi there,
    I tried posting this to another thread, however it is marked resolved
   and I am not sure if you happened to notice the request, so here’s a repost:
 * Can you implement a change that would allow having php code inside HTML fragments?
 * All you need to do is replace the following block of code inside the “gcb” function:
 *     ```
       if($entry['type']!="php") {
       	return apply_filters('gcb_block_output', do_shortcode($content));//make sure we also run the shortcodes in here
       }
       else
       {
       	//execute the php code
       	ob_start();
       	$result = eval(" ".$content);
       	$output = ob_get_contents();
       	ob_end_clean();
       	return apply_filters('gcb_block_output', do_shortcode($output . $result));//run the shortcodes as well
       }
       ```
   
 * with
 *     ```
       if($entry['type'] == "php") {
           //execute the php code
           ob_start();
           $result = eval(" ".$content);
           $output = ob_get_contents();
           ob_end_clean();
           return apply_filters('gcb_block_output', do_shortcode($output . $result));//run the shortcodes as well
       }
       elseif($entry['type'] == "html") {   // alloyphoto: enable PHP code in < ?php ... ? > tags inside blocks
           ob_start();
           eval("?>$content<?php ");
           $output = ob_get_contents();
           ob_end_clean();
           return apply_filters('gcb_block_output', do_shortcode($output));//run the shortcodes as well
       }
       else
       {
           return apply_filters('gcb_block_output', do_shortcode($content));//make sure we also run the shortcodes in here
       }
       ```
   
 * Thanks!
 * [https://wordpress.org/plugins/global-content-blocks/](https://wordpress.org/plugins/global-content-blocks/)

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

 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/php-code-inside-html-blocks/#post-6724346)
 * vlad13 I’ll definitely be considering this. Thank you for the suggestion.
 *  Plugin Author [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * (@delmarliske)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/php-code-inside-html-blocks/#post-6724462)
 * vlad13, this is included in version 2.1.0. Again, thank you.

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

The topic ‘PHP code inside HTML blocks’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/global-content-blocks_c8cac8.svg)
 * [Global Content Blocks](https://wordpress.org/plugins/global-content-blocks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/global-content-blocks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/global-content-blocks/)
 * [Active Topics](https://wordpress.org/support/plugin/global-content-blocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/global-content-blocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/global-content-blocks/reviews/)

## Tags

 * [block](https://wordpress.org/support/topic-tag/block/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 2 participants
 * Last reply from: [Dave Liske](https://wordpress.org/support/users/delmarliske/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/php-code-inside-html-blocks/#post-6724462)
 * Status: resolved