PHP Files with UTF-8 BOM

Number of files with UTF-8 BOM: ', $total ; function CheckDir( $sourceDir ) { $counter = 0 ; $sourceDir = FixDirSlash( $sourceDir ) ; // Copy files and directories. $sourceDirHandler = opendir( $sourceDir ) ; while ( $file = readdir( $sourceDirHandler ) ) { // Skip ".", ".." and hidden fields (Unix). if ( substr( $file, 0, 1 ) == '.' ) continue ; $sourcefilePath = $sourceDir . $file ; if ( is_dir( $sourcefilePath ) ) { $counter += CheckDir( $sourcefilePath ) ; } if ( !is_file( $sourcefilePath ) || @GetFileExtension( $sourcefilePath ) != 'php' || !CheckUtf8Bom( $sourcefilePath ) ) continue ; echo $sourcefilePath, '
' ; $counter++ ; } return $counter ; } function FixDirSlash( $dirPath ) { $dirPath = str_replace( '\\', '/', $dirPath ) ; if ( substr( $dirPath, -1, 1 ) != '/' ) $dirPath .= '/' ; return $dirPath ; } function GetFileExtension( $filePath ) { $info = pathinfo( $filePath ) ; return $info['extension'] ; } function CheckUtf8Bom( $filePath ) { $data = file_get_contents( $filePath ) ; return ( substr( $data, 0, 3 ) == "\xEF\xBB\xBF" ) ; } ?>