php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49688 ob_start() does not capture output to STDOUT
Submitted: 2009-09-27 18:54 UTC Modified: 2009-11-13 21:47 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ch at lathspell dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.3.0 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ch at lathspell dot de
New email:
PHP Version: OS:

 

 [2009-09-27 18:54 UTC] ch at lathspell dot de
Description:
------------
Output buffering does capture the output of print() and echo() but apparently not anything that goes to STDOUT (php://stdout) via fwrite().

That should preferably be fixed or at least be documented.

Reproduce code:
---------------
$ cat t.php
<?php
error_reporting(E_ALL);

ob_start();

echo "does work\n";

$f = fopen('php://stdout', 'w');
fwrite($f, "does not work\n");
fclose($f);

$v = ob_get_contents();
ob_end_clean();

print("CAPTURED: $v\n");


Expected result:
----------------
$ php t.php

CAPTURED: does not work
does work

Actual result:
--------------
$ php t.php
does not work
CAPTURED: does work


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-27 21:39 UTC] jani@php.net
Using php://stdout means you're by-passing output buffering 
intentionally. Perhaps a note or two could be in order in the docs..
 [2009-11-13 21:47 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2009-11-13 21:47 UTC] svn@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=290707
Log: php://stdout doesn't use output buffer (bug #49688)
 [2012-07-25 14:03 UTC] nicolas dot vanheu at gmail dot com
You might want to use php://output instead of php://stdout if your intention is 
to write to the output buffer.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 06:00:02 2025 UTC