php专区

 首页 > php专区 > PHP应用 > php函数大全 > 检测文件是否有bom头 - PHP

检测文件是否有bom头 - PHP

分享到:
【字体:
导读:
         [导读]

";
}
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);
}
分享到:
PHP天气API接口
中国天气网的API还每次还要先去判断ID,再获取天气信息,觉得有点麻烦,所以自己做了一个PHP一部搞定的。还有一个农历API。 城市源码 http://www.php100.com/uploadfile/2013/0923/20130923081358704.rar 无标题文档 ...
php获取从百度搜索进入网站的关键词
php获取从百度搜索进入网站的关键词
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……