3v4l.org

run code in 300+ PHP versions simultaneously
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output for 8.1.0 - 8.1.32, 8.2.0 - 8.2.28, 8.3.0 - 8.3.19, 8.4.1 - 8.4.5
bug Deprecated: Return type of SampleFilter::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/jEMEE on line 10 <pre>&lt;?php echo &#039;feature&#039;; // Should be transformed by filter on second include if (!class_exists(SampleFilter::class)) { class SampleFilter extends php_user_filter { private $data = &#039;&#039;; public function filter($in, $out, &amp;$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this-&gt;data .= $bucket-&gt;data; } if ($closing || feof($this-&gt;stream)) { $consumed = strlen($this-&gt;data); $this-&gt;data = str_replace(&#039;feature&#039;, &#039;feature&#039;, $this-&gt;data); $bucket = stream_bucket_new($this-&gt;stream, $this-&gt;data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register(&#039;sample.filter&#039;, SampleFilter::class); $uri = &#039;php://filter/read=sample.filter/resource=&#039;. __FILE__; $content = file_get_contents($uri); echo &#039;&lt;pre&gt;&#039;, htmlentities($content), &#039;&lt;/pre&gt;&#039;; // Looks good include $uri; // We expect one more &quot;feature&quot; output at line 3 }</pre>feature
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
bug<pre>&lt;?php echo 'feature'; // Should be transformed by filter on second include if (!class_exists(SampleFilter::class)) { class SampleFilter extends php_user_filter { private $data = ''; public function filter($in, $out, &amp;$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this-&gt;data .= $bucket-&gt;data; } if ($closing || feof($this-&gt;stream)) { $consumed = strlen($this-&gt;data); $this-&gt;data = str_replace('feature', 'feature', $this-&gt;data); $bucket = stream_bucket_new($this-&gt;stream, $this-&gt;data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register('sample.filter', SampleFilter::class); $uri = 'php://filter/read=sample.filter/resource='. __FILE__; $content = file_get_contents($uri); echo '&lt;pre&gt;', htmlentities($content), '&lt;/pre&gt;'; // Looks good include $uri; // We expect one more &quot;feature&quot; output at line 3 }</pre>feature

preferences:
184.07 ms | 417 KiB | 5 Q