|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-03 09:53 UTC] cweiske@php.net
Description:
------------
When issuing a header() call in a php command line script (php cli) after I used 'echo', the message 'headers already sent' pops up.
It should be possible to use header(), session_id_generate() and other session related functions after outputting something on CLI - since headers are not sent on cli.
(The use case we have is unit-testing packages on cli)
Reproduce code:
---------------
<?php
echo 'a';
header('sadf');
?>
Expected result:
----------------
a
Actual result:
--------------
a
Warning: Cannot modify header information - headers already sent by (output started at /data/cvs/pear/sessionbug.php:2) in /data/cvs/pear/sessionbug.php on line 3
Call Stack:
0.0003 83688 1. {main}() /data/cvs/pear/sessionbug.php:0
0.0006 83988 2. header() /data/cvs/pear/sessionbug.php:3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 04:00:01 2025 UTC |
Just use ob_start(). $ ./sapi/cli/php <?php ob_start(); echo 'a'; header('sadf'); ?> a