繁体   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