php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40429 headers sent when using php://output + ob_start
Submitted: 2007-02-10 12:34 UTC Modified: 2007-03-21 14:17 UTC
From: nicolas dot grekas+php at gmail dot com Assigned:
Status: Closed Package: Streams related
PHP Version: 5.1.2 OS: WIN
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:
46 + 21 = ?
Subscribe to this entry?

 
 [2007-02-10 12:34 UTC] nicolas dot grekas+php at gmail dot com
Description:
------------
Opening the php://output stream seams to flag the headers as sent, event if output buffering is on. Consequently, any call to header() fails where it shouldn't.

Affects any extension that uses streams.


Reproduce code:
---------------
<?php

ob_start();
$h = fopen('php://output', 'wb');
fclose($h);
ob_end_clean();

header('X-Foo: bar');

?>

Or

<?php

ob_start();
$dom = new DOMDocument;
$dom->save('php://output');
ob_end_clean();

header('X-Foo: bar');

?>

Expected result:
----------------
blank page

Actual result:
--------------
Warning: Cannot modify header information - headers already sent in C:\[...]\test.php on line 8

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-11 09:37 UTC] tony2001@php.net
Cannot reproduce with any of your examples.
Makes sure you're actually using 5.2.1 and not something old.
 [2007-02-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-03-21 14:17 UTC] nicolas dot grekas+php at gmail dot com
Sorry, I was experimenting the bug in PHP 5.1.2, not 5.2.1...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 13:01:29 2024 UTC