BOM Characters can cause issues in your website
http://en.wikipedia.org/wiki/Byte_order_mark
there a small characters put in your files text editors..
the last few weeks iv'e fixed a few sites with BOM trouble and there hard to find because you cant see them.
below is a script to find them out, run this script from your public_html folder and see if it can seek any out.
once found open the file in notepad++ and go to the drop-down menu "Encoding" and select "Encode UTF-8 Without BOM".
Save and upload the file and should be fixed.
BOM cases issues like "headers already sent" and invalid code when trying to validate html with w3c.
Just save it and run it then delete after your finished.
Peace
http://en.wikipedia.org/wiki/Byte_order_mark
there a small characters put in your files text editors..
the last few weeks iv'e fixed a few sites with BOM trouble and there hard to find because you cant see them.
below is a script to find them out, run this script from your public_html folder and see if it can seek any out.
once found open the file in notepad++ and go to the drop-down menu "Encoding" and select "Encode UTF-8 Without BOM".
Save and upload the file and should be fixed.
BOM cases issues like "headers already sent" and invalid code when trying to validate html with w3c.
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP BOM Finder</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family: arial, verdana, sans-serif }
p { margin-left: 20px }
</style>
</head>
<body>
<h1>UTF-8 BOM seek</h1>
<p>
<?php
$total = CheckDir( '../');
echo '<br /> 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 ) ){
echo 'CLEAN:'.$sourcefilePath. '<br />' ;
}else{
echo 'DETECTED:'.$sourcefilePath. '<br />' ;
}
$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" ) ;
}
?>
</p>
</body>
</html>
Just save it and run it then delete after your finished.
Peace