最小的脚本 - 仍然不能修改标题信息 - 已经发送的标题 [英] Minimal script--still getting Cannot modify header information - headers already sent

查看:142
本文介绍了最小的脚本 - 仍然不能修改标题信息 - 已经发送的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我疯狂。这似乎是一个简单的错误 - 我已经看到了几十个关于他们的脚本的帖子是更复杂,然后我。



我有一个PHP脚本,应该强制下载通过设置标题。

 <?php 
header(Content-Type:audio / MP3\" );
header(Content-Disposition:attachment; filename = \audio.mp3\;);
readfile(audio.mp3);
exit();
?>

为什么我的头文件被发送出去?我试过obj_start和obj_flush,但到目前为止没有运气。这可能是我的主机问题吗?我正在使用1and1.com

解决方案

您的脚本在测试时工作正常 - 确保您没有任何空格你的脚本的开始或结束。


This is driving me crazy. It seems like a simple error--I've seen dozens of posts about their scripts are way more complicated then mine.

I have a php script which should force a download by setting the headers. I've slimmed the script down to this:

<?php
header("Content-Type: audio/mp3");
header("Content-Disposition: attachment; filename=\"audio.mp3\";" );
readfile("audio.mp3");
exit();
?>

Why are my headers getting sent out? I tried obj_start and obj_flush, but so far no luck. Could this be a problem with my host? I'm using 1and1.com

解决方案

Your script works fine when tested -- make sure you don't have any spaces at the beginning or end of your script.

这篇关于最小的脚本 - 仍然不能修改标题信息 - 已经发送的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆