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
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: nicolas dot grekas+php at gmail dot com
New email:
PHP Version: OS:

 

 [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: Tue Apr 23 12:01:31 2024 UTC