Edit report at https://bugs.php.net/bug.php?id=42197&edit=1
ID: 42197
Comment by: dsnaga78 at gmail dot com
Reported by: cweiske@php.net
Summary: header() cannot be used after echo on CLI
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: Linux
PHP Version: 5.2.4RC1
Block user comment: N
Private report: N
New Comment:
There is no need to remove header from CLI. Why not adding a setting in php.ini to turn headers
on/off? Something like:
cli_output.headers = On
Default is on, which is consistent with the existing behavior.
Such a setting will be used by CLI only and will definitely help in situations like those reported
by the OP.
Previous Comments:
------------------------------------------------------------------------
[2015-01-12 20:30:54] yohgaki@php.net
BTW, I cannot remove header() from CLI. CLI has built-in web server now.
------------------------------------------------------------------------
[2015-01-12 20:27:24] yohgaki@php.net
Header cannot be sent if body is sent already. It's the definition of HTTP. I fail to see
what's wrong with this.
Besides, what the reason you need to call header() with CLI other than testing?
------------------------------------------------------------------------
[2015-01-12 19:57:39] aharvey@php.net
I'm confused: isn't it a _good_ thing that the CLI behaves the same way as other SAPIs in
terms of header() handling for testing?
------------------------------------------------------------------------
[2015-01-10 13:21:46] cweiske@php.net
@ajf: Not, those are not better questions.
If you had read the bug report description, you'd have noticed that I run unit tests which run
code that uses header(). 14 plus votes do also stand against your "better question".
------------------------------------------------------------------------
[2015-01-09 00:52:23] ajf@php.net
Perhaps a better question is why header() is even available on CLI, or why you're using it in
CLI.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=42197
--
Edit this bug report at https://bugs.php.net/bug.php?id=42197&edit=1