简体   繁体   English

如何删除警告无法修改标头信息-标头已发送

[英]How to remove warning Cannot modify header information - headers already sent by

A "headers already sent" warning arises .I close $zip->close(); 出现“已发送标题”警告。我关闭$zip->close(); but still show warning 但仍然显示警告

$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");

At the start of your script, use: 在脚本的开头,使用:

<?php ob_start(); ?>

Then at the end of your script, add: 然后在脚本末尾添加:

<?php ob_flush(); ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:无法修改标头信息-标头已发送 - Warning: Cannot modify header information - headers already sent by 警告:无法修改标题信息 - 标题已在 wordpress 中发送 - Warning: Cannot modify header information - headers already sent by in wordpress 无法修改标题信息-标题已发送 - Cannot modify Header Information - headers already sent 无法修改标头信息 - 标头已发送 - Cannot modify header information - headers already sent 无法修改标头信息-标头已由发送 - Cannot modify header information - headers already sent by 无法修改已发送的标头信息标头 - Cannot Modify Header Information Headers Already Sent 关于警告的奇怪错误:无法修改标题信息-没有空格PHP时已经发送的标题 - Strange error regarding Warning: Cannot modify header information - headers already sent by when there is no white space PHP Wordpress提要:PHP警告无法修改标题信息-标题已发送 - Wordpress Feeds: PHP Warning Cannot modify header information - headers already sent 为什么我没有收到“警告:无法修改标头信息-标头已经发送”的信息,我希望得到它? - Why I'm not getting a 'Warning: Cannot modify header information - headers already sent by' as I expected to get one? PHP setcookie()给出“无法修改标题信息 - 标题已发送”警告 - PHP setcookie() gives “Cannot modify header information – headers already sent” warning
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM