The PHP program is put on the server, and everything else is normal. When calling XML data, the FF test is normal, but an error occurs in IE. The length displayed each time is different, the httpwatch captured the packet and looked at it normally. It seems that the content on the server is normal.
Problem Analysis: Cause of speculation: What is caused by Chinese characters? But it was immediately rejected because the pure XML file was uploaded to the server, and the CDATA contains Chinese characters and can be displayed normally.
Analysis result: Finally, we found that it was originally caused by BOM.
The code for removing Bom is as follows:
// Remove the UTF-8 BOMs
// By magicbug at gmail dot com
If (isset ($ _ Get ['dir']) {
// Config the basedir
$ 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"). "<br> ";
} 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 ("<font color = Red> BOM found, automatically removed. </font> ");
} Else {
Return ("<font color = Red> BOM found. </font> ");
}
}
Else return ("Bom not found .");
}
Function rewrite ($ filename, $ data ){
$ Filenum = fopen ($ filename, "W ");
Flock ($ filenum, lock_ex );
Fwrite ($ filenum, $ data );
Fclose ($ filenum );
}
?>