|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30583 echo and print not filtered when stream filter installed on php://output..
Submitted: 2004-10-27 16:39 UTC Modified: 2020-08-24 19:59 UTC
Avg. Score:4.1 ± 1.0
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:2 (33.3%)
From: tobe at stonecodex dot com Assigned: kalle (profile)
Status: Closed Package: *General Issues
PHP Version: 7.1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tobe at stonecodex dot com
New email:
PHP Version: OS:


 [2004-10-27 16:39 UTC] tobe at stonecodex dot com
print and echo are not filtered when a stream filter is installed on php://output. 

Whilst there are workarounds they are either not as flexible (using output_handler) or not as convenient (changing all my echos to fwrites) as the filter pattern. 

Would argue that if this behaviour is by design then the design should be changed or at the very least the documentation amended to reflect this situation.

Reproduce code:
class strtoupper_filter extends php_user_filter 
  function filter($in, $out, &$consumed, $closing)
   while ($bucket = stream_bucket_make_writeable($in)) {
     $bucket->data = strtoupper($bucket->data);
     $consumed += $bucket->datalen;
     stream_bucket_append($out, $bucket);
   return PSFS_PASS_ON;
stream_filter_register("strtoupper", "strtoupper_filter");

$fp = fopen("php://output", "w");
stream_filter_append($fp, "strtoupper");

echo "echo: testing 123<br>";
print("print: testing 123<br>");
fwrite($fp, "fwrite: testing 123<br>");

Expected result:

Actual result:
echo: testing 123
print: testing 123


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-20 20:34 UTC]
-Type: Feature/Change Request +Type: Bug -Package: Feature/Change Request +Package: *General Issues -PHP Version: 5CVS-2005-03-07 +PHP Version: 7.1
 [2017-01-20 20:34 UTC]
This still seems to be an issue…
 [2020-08-24 19:59 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2020-08-24 19:59 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Both `echo` and `print` are implemented in ZE and the user streams are apart of the standard library.

I'm gonna close this as it does not seem to be a bug but rather a design choice. 

You are of course welcome to request a feature request if you need this behavior changed, though I forsee as unlikely. Sorry it took almost 16 years to get here, but I promise it won't take another 16 years for the next reply!
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 13:01:26 2023 UTC