php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #28613 Output sent before header or setcookie
Submitted: 2004-06-02 23:24 UTC Modified: 2004-06-03 09:36 UTC
From: jsgoupil at lookstrike dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.0.0RC2 OS: WinXP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 26 = ?
Subscribe to this entry?

 
 [2004-06-02 23:24 UTC] jsgoupil at lookstrike dot com
Description:
------------
In the documentation : "Remember that header() must be called before any actual output is sent..."
We can find the same in setcookie() function.

In PHP5, when we use
header("Location: http://www.lookstrike.com");
, the function doen't care if we sent something before.

If other function exists like that, perhaps it will do the same thing...

php.ini file : 
display_error = On
error_reporting = E_ALL

I don't know if you have to clarify the docs or if it is a function bug...

Reproduce code:
---------------
<?php
echo "A";
header("Location: http://www.lookstrike.com"); // Going to Website
?>

of

<?php
echo "A";
setcookie("TEST"); // No error
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-03 09:36 UTC] vrana@php.net
It works for you because you have output_buffering turned on. It's explained well in the documentation:

In PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 04:01:30 2024 UTC