|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-18 14:49 UTC] php_nospam at ramihyn dot sytes dot net
Description:
------------
The example provided for stream_filter_remove() does not work as expected.
Reproduce code:
---------------
<?php
$fp = fopen("test.txt", "w");
$rot13_filter = stream_filter_append($fp, "string.rot13", STREAM_FILTER_WRITE);
fwrite($fp, "This is ");
stream_filter_remove($rot13_filter);
fwrite($fp, "a test\n");
rewind($fp);
fpassthru($fp);
fclose($fp);
?>
Expected result:
----------------
Guvf vf a test
Actual result:
--------------
(no output)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 17:00:01 2025 UTC |
Also there seems to be a problem with other filters: the below example hangs at fread(), if the script rewind()s the stream. If closing the file and opening a new file handle, everyhing works as expected. <?php $str = "The quick brown fox jumps over the lazy dog."; $fp = fopen("test.bin","w"); $bz_filter = stream_filter_append($fp,"bzip2.compress",9); fwrite($fp,$str,strlen($str)); stream_filter_remove($bz_filter); #fclose($fp); #fopen($fp,"test.bin","r+"); rewind($fp); $bz_filter = stream_filter_append($fp,"bzip2.decompress"); $str2 = fread($fp,strlen($str)); stream_filter_remove($bz_filter); fclose($fp); var_dump($str2); ?>If using the bzip2.compress or zlib.deflate filters, ftell() returns the same value as before using the filter to write to the stream: <?php $s = "The quick brown fox jumps over the lazy dog."; $fp = fopen("test.bin","w"); fwrite($fp,$s); var_dump(ftell($fp)); // int(44) $filter = stream_filter_append($fp,"zlib.deflate",STREAM_FILTER_WRITE,9); fwrite($fp,$s); stream_filter_remove($filter); var_dump(ftell($fp)); // int(44) fclose($fp); ?>