Skip to content

Instantly share code, notes, and snippets.

View mdoelker's full-sized avatar

Malte Dölker mdoelker

  • Pirate Ship
  • Germany
View GitHub Profile
@mdoelker
mdoelker / fix_utf8_bom.php
Created February 28, 2014 11:17
Script that recursively strips the UTF-8 Byte Order Mark (BOM) from matching files in a given directory. BOMs are bad in PHP, especially when using output buffering or namespaces. This script helps fixing your codebase.
<?php
/**
* Remove BOM from a single file
*
* @param string $filename
* @return bool
*/
function stripUtf8BomFromFile($filename) {
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);