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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2021 The PHP Group
All rights reserved.
Last updated: Sun Aug 01 02:01:24 2021 UTC