doudi1750 2018-12-12 20:33
浏览 109
已采纳

是否存在触发阻止标头已发送的HTTP标头大小限制?

Maybe I am missing something, but unfortunately the above suggested link did not help me with the following problem:

I have a file (doctype_head.php) that also has an include of an authentication file for logins that I load first thing on all my webpages. Last time I logged in to check my login-system index.php file I got this warning:

Warning: Cannot modify header information - headers already sent by (output started at www.haushalts-geld.de\include\doctype_head.php:40) in www.haushalts-geld.de\login\admin\index.php on line 53

I know I get this warning because of a header() call in line 53 in index.php and I also know how to fix it. This warning seems connected to the amount of characters in "doctype_head.php". As far as I know no output is sent before the aforementioned header() call. Otherwise deleting just a few characters from my comments text (<!--bla bla-->) in "doctype_head.php" would not have solved the headers already sent warning, I guess. The thing is, everything works fine only if I keep the text in "doctype_head.php" to a certain length. I tested it up to the point where I just have to add one single character to "doctype_head.php" and get the above warning. If I remove this character again, everything works without warning.

So, that's why I wonder if it could be that I am only allowed a certain amount of characters for my HTTP header before my output starts? I thought that the included authentication file within "doctype_head.php" might be the culprit, since this alone is already about 6KB. If so, what can I do to fix this? And if not, any ideas what else I am missing? Thanks for your help.

  • 写回答

1条回答 默认 最新

  • dongxia2068 2018-12-12 23:57
    关注

    So, that's why I wonder if it could be that I am only allowed a certain amount of characters for my HTTP header before my output starts?

    Not usually. Something in your application has to output something for output to begin.

    Otherwise deleting just a few characters from my comments text (<!--bla bla-->) in "doctype_head.php" would not have solved the headers already sent warning

    Your comment style is using HTML comments... not PHP comments. Anything outside of PHP open/close tags is going to be output, including HTML comments. PHP doesn't really know or care about HTML. It's just going to output it. Use PHP comments instead, inside PHP tags. (/* comment */) Better yet, never close your PHP tag. It's not necessary that you close it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的