异常的“标头已发送”错误。没有空格,也没有改变标题

发布于 2024-11-24 05:56:42 字数 675 浏览 3 评论 0 原文

在你开始告诉我之前,我知道已经有 10000000 个关于此错误的帖子了。

我正在开发一个 WordPress 插件,并在提交编辑页面时收到以下错误:

Warning: Cannot modify header information - headers already sent by (output started at ***\wp-content\plugins\***\meta-class-load.php:1067) in ***\wp-includes\pluggable.php on line 934

此错误的不同之处在于它引用的行不与标题交互,也不输出之前的内容。我检查了 php 标签周围的空白,没有:P

这是第 1067 行的内容(和周围):

        $name = $field['id'];
        $type = $field['type'];
        $old  = $this->get_meta($post->ID, $field); // THIS IS THE LINE
        $new = isset($_POST[$name]) ? $_POST[$name] : ($field['multiple'] ? array() : '');

任何想法或解决方案都会有帮助。谢谢!

Before you start telling me there are already 10000000 posts on this error, I know.

I am working on a wordpress plugin and am recieving the following error when submitting my edit pages:

Warning: Cannot modify header information - headers already sent by (output started at ***\wp-content\plugins\***\meta-class-load.php:1067) in ***\wp-includes\pluggable.php on line 934

What's different about this error is the line it references does not interface with the header, nor output content before. I have checked for whitespace surrounding php tags, and there is none :P

This is the contents (and surrounds) of line 1067:

        $name = $field['id'];
        $type = $field['type'];
        $old  = $this->get_meta($post->ID, $field); // THIS IS THE LINE
        $new = isset($_POST[$name]) ? $_POST[$name] : ($field['multiple'] ? array() : '');

Any ideas or solutions would be helpful. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

記憶穿過時間隧道 2024-12-01 05:56:45

1067是输出内容的行。第 934 行是设置标题的行。我认为你把它们搞反了。

1067 is the line that outputs content. Line 934 is the one setting the header. I think you have them backwards.

云归处 2024-12-01 05:56:45

在发送所有标头之前无法发送任何输出。错误中列出的文件之一或可能是这些文件之一包含的文件正在输出某些内容。它可能是故意的、一点零散的空白、警告或错误消息。

为了防止出现错误,您可以尝试调用 ob_clean();或 ob_end_clean();在标头调用之前清除输出缓冲区。 ob_end_clean();在这些情况下几乎总是成功的。

No output can be sent before all headers are sent. One of the files listed in the error, or possibly a file included by one of those files, is outputting something. It could be something intentional, a stray bit of white space, a warning or an error message.

To prevent the error you can try calling either ob_clean(); or ob_end_clean(); to clear the output buffer right before your header call. ob_end_clean(); is almost always successful in these cases.

じее 2024-12-01 05:56:44

在发送 HEADER 之前切勿输出任何内容,如果这样做,您将无法发送标头并且会抛出错误!
在生产服务器上设置 error_reporting(0) 也是一个很好的做法,以确保在 header 之前不会显示错误

Never output anything before sending the HEADER, if you do so you will not be able to send the header and it will throw an error !
It's also a good practice to set error_reporting(0) on production server to make sure that no error gets shown before header

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文