php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #30583 echo and print not filtered when stream filter installed on php://output..
Submitted: 2004-10-27 16:39 UTC Modified: 2005-03-07 22:27 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: tobe at stonecodex dot com Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5CVS-2005-03-07 OS: *
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-27 16:39 UTC] tobe at stonecodex dot com
Description:
------------
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:
----------------
ECHO: TESTING 123
PRINT: TESTING 123
FWRITE: TESTING 123

Actual result:
--------------
echo: testing 123
print: testing 123
FWRITE: TESTING 123

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 23:01:58 2014 UTC