D7: function calls too early (before DOCTYPE) and mess my page
You need to return your HTML string as the page callback rather than outputting it directly...otherwise what your doing is incompatible with the the Drupal theme system, and is why you're getting the problem you're getting at the moment.

Without seeing all of your code its impossible to debug this completely but suffice to say that in whichever page callback function you're calling display_container() you want to do this instead:

// Start the output buffer
ob_start();

// This will perform the echo to your new local buffer, not the screen buffer.
display_container();

// Get the temporary buffer content into a variable.
$output = ob_get_clean();

// Return the page callback to Drupal as normal
return $output;


If you're in a block view (which I seem to recall you might be from one of your previous questions) that last line would be:

$block['content'] = $output;


The other, perhaps simpler method here, would be to simply change your display_container() function to return the string rather than output it directly:

public function display_container(){
  $container = "&lt;div id='jcart' class='jcart1'&gt;";
  $container .= "&lt;/div&gt;";      
  $container .= "&lt;div id='jcart-tooltip'&gt;&lt;/div&gt;\n";

  return $container;
}