php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34627 fopen('php://stdout') / fputs() doesn't send output under Apache2 SAPI
Submitted: 2005-09-24 10:37 UTC Modified: 2005-10-13 18:48 UTC
From: drewish at katherinehouse dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.0.5 OS: Windows XP / FreeBSD 5
Private report: No CVE-ID: None
 [2005-09-24 10:37 UTC] drewish at katherinehouse dot com
Description:
------------
I'm trying to move some code that was written for the CLI to the web. It makes extensive use fprintf() and fputs() and under Apache2 it give no output. 

Reproduce code:
---------------
<?php
$fp = fopen('php://stdout', 'w');
if ($fp === false) {
    die('open failed.');
}
print "You can see this with the CLI and Apache.\n";
fputs($fp, "This only shows up on the CLI...\n");
fclose($fp);
?>


Expected result:
----------------
Under FreeBSD:
  amorton@multivac:/home/www/multivac> php phptest.php
  You can see this with the CLI and Apache.
  This only shows up on the CLI...

Under Windows XP:
  D:\temp>php phptest.php
  You can see this with the CLI and Apache.
  This only shows up on the CLI...

Actual result:
--------------
Viewing the page using Apache2 and mod_php5:
  You can see this with the CLI and Apache.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-24 11:47 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2005-09-25 09:39 UTC] drewish at katherinehouse dot com
Why do 'php://output' and 'php://stdout' go to different places under Apache but not the CLI?
 [2005-09-25 09:51 UTC] drewish at katherinehouse dot com
I forgot to link to http://php.net/manual/en/wrappers.php.php which says php://stdout allow access to the output stream while php://output allows you to write to the output buffer mechanism. Shouldn't stdout and output be going to the same place?
 [2005-09-28 21:13 UTC] drewish at katherinehouse dot com
I apologize for reopening this but I've tried to find an explanation for the strange (read buggy) behavoir using several of the support resources you linked to with no luck. Everyone seems to think that php://stdout and php://output should both act identically under Apache, as they do under the CLI. 

If you're going to mark this as bogus again, please do me the favor of a short explanation of where data sent to php://stdout under Apache ends up.
 [2005-10-13 15:18 UTC] vrana@php.net
AFAIK PHP Apache module doesn't output directly but through output buffering. Thus output stream of the PHP process in Apache module leads nowhere and you have to use php://stdout.
 [2005-10-13 18:48 UTC] drewish at katherinehouse dot com
vrana@php.net, I appreciate your comment but it doesn't 
really make any sense. My problem was that stdout 
doesn't work under Apache, you indicate that it should 
work. 

Either way, at this point I've given up on getting a 
straight answer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 06:01:35 2024 UTC