[英]How to remove warning Cannot modify header information - headers already sent by
出現“已發送標題”警告。我關閉$zip->close();
但仍然顯示警告
$zip = new ZipArchive;
$download = 'new_zip.zip';
$zip->open($download, ZipArchive::CREATE);
foreach (glob("zipfile/*") as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename = $download");
header('Content-Length: ' . filesize($download));
header("Location: $download");
在腳本的開頭,使用:
<?php ob_start(); ?>
然后在腳本末尾添加:
<?php ob_flush(); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.