如何诊断错误:无法添加cookie,标头已发送


How to diagnose error : Unable to add cookies, header already sent

错误:无法添加 cookie,标头已发送。

我想知道是否有任何方法可以有效地诊断上述错误。
我了解此错误的原因 - 当 cookie 在发送到浏览器后发送其他内容(例如标头、html 等(时。

有数百个文件,包含数千行代码。如果有人知道一种方法(即使是第三方,也没关系(,这将帮助我在 cookie 之前找到哪些内容发送到浏览器,以便我可以轻松操作这部分代码。我在查找导致此错误的实际地点或代码补丁时遇到问题。

通常,这发生在许多vBulletin用户身上,vB工作人员告诉您禁用mods/插件等。但是我想知道找到问题位置的任何有效方法。<?php等没有问题。

在 cookie 设置时header_sent()参考函数.php函数 header_sent(( 可以为您提供帮助。

bool headers_sent ([ string &$file [, int &$line ]] )
If the optional file and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the file and line variables.