簡體   English   中英

如何刪除警告無法修改標頭信息-標頭已發送

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM