3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyFilter extends php_user_filter { public function filter($in, $out, &$consumed, $closing) { stream_bucket_make_writeable($in); return PSFS_ERR_FATAL; } } stream_filter_register('filtername', MyFilter::class); $source_resource = fopen('php://memory', 'rb+'); fwrite($source_resource, 'Test data'); rewind($source_resource); stream_filter_prepend($source_resource,'filtername',STREAM_FILTER_READ); var_dump(stream_copy_to_stream($source_resource, fopen('php://memory', 'wb')));
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Deprecated: Return type of MyFilter::filter($in, $out, &$consumed, $closing) should either be compatible with php_user_filter::filter($in, $out, &$consumed, bool $closing): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/dD9ZH on line 4 bool(false)
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
bool(false)

preferences:
129.41 ms | 408 KiB | 5 Q