是否存在触发阻止 header 已发送的 HTTP header 大小限制?
Is there a HTTP header size limit that triggers prevent header already sent?
也许我遗漏了什么,但不幸的是,上面的建议 link 并没有帮助我解决以下问题:
我有一个文件 (doctype_head.php),其中还包含一个用于登录的身份验证文件,我首先会在所有网页上加载该文件。上次我登录检查我的 login-system index.php 文件时,我收到了这个警告:
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
我知道我收到此警告是因为 index.php 中第 53 行的 header() 调用,我也知道如何修复它。此警告似乎与 "doctype_head.php" 中的字符数有关。据我所知,在上述 header() 调用之前没有发送任何输出。否则从我在 "doctype_head.php" 中的评论文本 (<!--bla bla-->
) 中删除几个字符将无法解决 header 已经发送的警告,我猜。问题是,只有当我将 "doctype_head.php" 中的文本保持一定长度时,一切才能正常工作。我对其进行了测试,直到我只需要将一个字符添加到 "doctype_head.php" 并得到上述警告。如果我再次删除此字符,一切都会在没有警告的情况下运行。
所以,这就是为什么我想知道在我的输出开始之前我的 HTTP header 是否只允许一定数量的字符?我认为 "doctype_head.php" 中包含的身份验证文件可能是罪魁祸首,因为仅此一项就已经有 6KB 左右了。如果是这样,我该怎么做才能解决这个问题?如果没有,我还有什么想法吗?感谢您的帮助。
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?
通常不会。您的应用程序中的某些内容必须输出一些内容才能开始输出。
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
您的评论风格使用的是 HTML 评论...而不是 PHP 评论。 PHP open/close 标签之外的任何内容 都将被输出,包括 HTML 评论。 PHP 并不真正了解或关心 HTML。它只是要输出它。在 PHP 标签内使用 PHP 注释。 (/* comment */
) 更好的是,永远不要关闭您的 PHP 标签。您不必关闭它。
也许我遗漏了什么,但不幸的是,上面的建议 link 并没有帮助我解决以下问题:
我有一个文件 (doctype_head.php),其中还包含一个用于登录的身份验证文件,我首先会在所有网页上加载该文件。上次我登录检查我的 login-system index.php 文件时,我收到了这个警告:
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
我知道我收到此警告是因为 index.php 中第 53 行的 header() 调用,我也知道如何修复它。此警告似乎与 "doctype_head.php" 中的字符数有关。据我所知,在上述 header() 调用之前没有发送任何输出。否则从我在 "doctype_head.php" 中的评论文本 (<!--bla bla-->
) 中删除几个字符将无法解决 header 已经发送的警告,我猜。问题是,只有当我将 "doctype_head.php" 中的文本保持一定长度时,一切才能正常工作。我对其进行了测试,直到我只需要将一个字符添加到 "doctype_head.php" 并得到上述警告。如果我再次删除此字符,一切都会在没有警告的情况下运行。
所以,这就是为什么我想知道在我的输出开始之前我的 HTTP header 是否只允许一定数量的字符?我认为 "doctype_head.php" 中包含的身份验证文件可能是罪魁祸首,因为仅此一项就已经有 6KB 左右了。如果是这样,我该怎么做才能解决这个问题?如果没有,我还有什么想法吗?感谢您的帮助。
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?
通常不会。您的应用程序中的某些内容必须输出一些内容才能开始输出。
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
您的评论风格使用的是 HTML 评论...而不是 PHP 评论。 PHP open/close 标签之外的任何内容 都将被输出,包括 HTML 评论。 PHP 并不真正了解或关心 HTML。它只是要输出它。在 PHP 标签内使用 PHP 注释。 (/* comment */
) 更好的是,永远不要关闭您的 PHP 标签。您不必关闭它。