php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49690 ob_start() does not capture output to STDOUT
Submitted: 2009-09-27 18:57 UTC Modified: 2009-09-27 20:38 UTC
From: ch at lathspell dot de Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.3.0 OS: Linux
Private report: No CVE-ID: None
 [2009-09-27 18:57 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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-27 20:38 UTC] felipe@php.net
See #49688
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 13:01:30 2024 UTC