There may be a lot of people come across in PHP if it is UTF8 encoding we import the file will appear blank line problem, below I will give you the reference file blank line solution.
A reference file refers to a blank line that is caused by an include, require_once reference to another file
This is actually you use Notepad to edit UTF-8 file, although you still save as UTF-8 format, but the system will automatically add two BOM mark, but IE can only ignore one, the other is blank line.
The solution is:
Do not use Notepad to edit the UTF-8 file, use other tools, than DREAMW, EmEditor, Visual Studio 2008 and other editing tools to edit UTF-8 file after saving.
My two stations with Notepad edit the top of the blank line, initially thought to be a CSS setup problem, the result is BOM tag caused.
There is another way, if you are a lot of files so we can use a PHP function to fix
Copy the following code into a php file, and then put in the need to clear the BOM header of the directory run, you can batch the first line of PHP blank to clear out, too to force.
The code is as follows |
Copy Code |
if (Isset ($_get[' dir ')) {//Set file directory $basedir =$_get[' dir ']; }else{ $basedir = '. '; } $auto = 1; Checkdir ($basedir); function Checkdir ($basedir) { if ($dh = Opendir ($basedir)) { while (($file = Readdir ($DH))!== false) { if ($file! = '. ' && $file! = ' ... ') { if (!is_dir ($basedir. " /". $file)) { echo "FileName: $basedir/$file". Checkbom ("$basedir/$file"). " "; }else{ $dirname = $basedir. " /". $file; Checkdir ($dirname); } } } Closedir ($DH); } } function Checkbom ($filename) { Global $auto; $contents = file_get_contents ($filename); $charset [1] = substr ($contents, 0, 1); $charset [2] = substr ($contents, 1, 1); $charset [3] = substr ($contents, 2, 1); if (Ord ($charset [1]) = = 239 && ord ($charset [2]) = = 187 && ord ($charset [3]) = = 191) { if ($auto = = 1) { $rest = substr ($contents, 3); Rewrite ($filename, $rest); Return ("BOM found, automatically removed."); } else { Return ("BOM found."); } } else return ("BOM not Found."); } function rewrite ($filename, $data) { $filenum = fopen ($filename, "w"); Flock ($filenum, LOCK_EX); Fwrite ($filenum, $data); Fclose ($filenum); } ?> |
http://www.bkjia.com/PHPjc/632081.html www.bkjia.com true http://www.bkjia.com/PHPjc/632081.html techarticle There may be a lot of people come across in PHP if it is UTF8 encoding we import the file will appear blank line problem, below I will give you the reference file blank line solution. Reference ...