title: How to remove multiple UTF-8 BOM sequences
body: <p>Using PHP5 (cgi) to output template files from the filesystem and having issues spitting out raw HTML.</p>
  
  <pre><code>private function fetch($name) {
      $path = $this-&gt;j-&gt;config['template_path'] . $name . '.html';
      if (!file_exists($path)) {
          dbgerror('Could not find the template "' . $name . '" in ' . $path);
      }
      $f = fopen($path, 'r');
      $t = fread($f, filesize($path));
      fclose($f);
      if (substr($t, 0, 3) == b'\xef\xbb\xbf') {
          $t = substr($t, 3);
      }
      return $t;
  }
  </code></pre>
  
  <p>Even though I've added the BOM fix I'm still having problems with Firefox accepting it. You can see a live copy here: <a href="http://ircb.in/jisti/" rel="noreferrer">http://ircb.in/jisti/</a> (and the template file I threw at <a href="http://ircb.in/jisti/home.html" rel="noreferrer">http://ircb.in/jisti/home.html</a> if you want to check it out)</p>
  
  <p>Any idea how to fix this? o_o</p>