本篇文章為大家展示了利用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 ("<font color=red>BOM found, automatically removed.</font>");
}else {
return ("<font color=red>BOM found.</font>");
}
}else return ("BOM Not Found.");
}php清除莫明輸出大法,用于輸出圖片前把前面所有輸出清空
只要在header前連用兩個函數,就可以解決...
ob_get_clean();
ob_clean();
header("Content-type: image/jpeg");附幾個好用的BOM檢測工具:
BOM檢測.zip


上述內容就是利用php怎么對bom進行清除,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。