如何从下载文件中删除BOM表标记


How remove BOM mark from download file?

我有这个脚本让用户下载文件:

header('Content-Encoding: UTF-8');
header("Content-Type:   application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: attachment; filename=qa_report.xlsx");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
// echo excel file ...
exit;

文件总是有BOM表标记,我怎么不能删除BOM表标记?

我解决了这个问题。问题不是脚本文件编码,而是其他包含文件没有用UTF8编码,没有BOM。所有包含的文件都必须具有相同的编码。