php如何使用代码清除bom,使用php清除bom示例
核心代碼
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.");
}
php清除莫明輸出大法,用于輸出圖片前把前面所有輸出清空
只要在header前連用兩個函數,就可以解決...
ob_get_clean();
ob_clean();
header("Content-type: image/jpeg");
附幾個好用的BOM檢測工具:
BOM檢測.zip
時間: 2014-03-02
總結
以上是生活随笔為你收集整理的php如何使用代码清除bom,使用php清除bom示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab 单元,MATLAB单元阵列
- 下一篇: matlab输入数组换行,三维数组换行输