Add meta tags when block exist on page and its cached
Instead of adding php code in the block you could add the code in a preprocess function for the block.

/**
 * Implements template_preprocess_block().
 */
function MYTHEME_preprocess_block(&amp;$variables) {
  if ($variables['block']-&gt;bid == 'MYBLOCKID') {
    $og_title = array(
      '#tag' =&gt; 'meta',
      '#attributes' =&gt; array(
        'property' =&gt; 'og:title', 
        'content' =&gt; "My example title",
      ),
    );
    drupal_add_html_head($og_title, 'MYMODULE_og_title');
  }
}