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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jsgoupil at lookstrike dot com
New email:
PHP Version: OS:

 

 [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: Wed Apr 24 08:01:29 2024 UTC