doudi1750 2018-12-12 12: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 15: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.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部