记住,php文件最好不要用window的记事本打开!状态200,parererror错误,在network下看到返回的Response下的结果集前面有个小红点点,这个问题困扰我一天,百度最好得出的结论是有php文件下包含了BOM头,但是我找不到,现在解决了,分享给大家。 我在某码之家里面找到了一段代码,然后找到一个方法,在想要检测的文件夹的同级目录下随便建一个php例如,aa.php,返回在里面写一段代码,去BOM就成了,这是网址http://www.th7.cn/Program/php/201606/889941.shtml;;;;;;;;;代码是这个:<?php
if(isset($_GET['dir'])){ //config the ba
sedir
$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);
}
?>
附件
123.png
( 1.97 KB 下载:24 次 )