1--TEST-- 2Testing user filter on streams 3--FILE-- 4<?php 5class Intercept extends php_user_filter 6{ 7 public static $cache = ''; 8 public function filter($in, $out, &$consumed, $closing) 9 { 10 while ($bucket = stream_bucket_make_writeable($in)) { 11 self::$cache .= $bucket->data; 12 $consumed += $bucket->datalen; 13 stream_bucket_append($out, $bucket); 14 } 15 return PSFS_PASS_ON; 16 } 17} 18 19$out = fwrite(STDOUT, "Hello\n"); 20var_dump($out); 21 22stream_filter_register("intercept_filter", "Intercept"); 23stream_filter_append(STDOUT, "intercept_filter"); 24 25$out = fwrite(STDOUT, "Goodbye\n"); 26var_dump($out); 27?> 28--EXPECT-- 29Hello 30int(6) 31Goodbye 32int(8) 33