Req #77758 [Com]: Warning: headers already sent should identify what triggered the send

From: Date: Sun, 17 Mar 2019 22:08:43 +0000
Subject: Req #77758 [Com]: Warning: headers already sent should identify what triggered the send
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220019@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77758&edit=1 ID: 77758 Comment by: spam2 at rhsoft dot net Reported by: webmaster at jamescobban dot net Summary: Warning: headers already sent should identify what triggered the send Status: Open Type: Feature/Change Request Package: Apache2 related Operating System: linux PHP Version: 7.2.16 Block user comment: N Private report: N New Comment: > print ''; // empty string > header("Content-Type: application/json"); just don't echo / print anything ebfore headers, it's that easy > headers already sent is one of the big time-wasters just don't output anything when you intend send headers after, easy > All of the documentation on this message including > hundreds of web-pages and forum discussions just start your application with ob_start() and the problem is forever, easy Previous Comments: ------------------------------------------------------------------------ [2019-03-17 22:03:19] webmaster at jamescobban dot net Description: ------------ The message Warning: Cannot modify header information - headers already sent is one of the big time-wasters of our profession. All of the documentation on this message including hundreds of web-pages and forum discussions end up as just a long list of things that the program MIGHT have done that would cause this message to appear. There is no documentation of exactly how a programmer should go about identifying exactly what the, usually trivial, mistake was that triggered the early send of the headers. The message should include information that directly points at the program action that caused PHP to send the headers. Test script: --------------- print ''; // empty string header("Content-Type: application/json"); Expected result: ---------------- Warning: Cannot modify header information - headers already sent because of backtrace to line 1. Actual result: -------------- Warning: Cannot modify header information - headers already sent at line 2. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77758&edit=1

« previous php.bugs (#220019) next »