From:
Operating system: Linux
PHP version: 5.3.8
Package: CGI/CLI related
Bug Type: Bug
Bug description:header() / setcookie() / session_start() give bogus warning
Description:
------------
SAPIs that do not support HTTP header(s), give warnings that output has
been already sent like
"Warning: Cannot modify header information - headers already sent by..."
even those APIs do *not* support headers.
There is no use to warn about something that can never happen; There is
nothing to modify; There are no headers that already have been sent.
It might make more sense to warn that this function is useless w/o HTTP
response headers being available.
Compare with headers_sent(), it does differ between SAPIs.
Would be nice to have this a bit more streamlined.
Additionally header() could return FALSE if it failed like setcookie().
Test script:
---------------
In CLI:
<?php
echo "output";
session_start();
setcookie("TestCookie", 'value');
header('X-TestHeader: value');
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=55850&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55850&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55850&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55850&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55850&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55850&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55850&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55850&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55850&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55850&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55850&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55850&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55850&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55850&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55850&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55850&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55850&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55850&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55850&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55850&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55850&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55850&r=mysqlcfg