3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SourceTransformingLoader extends php_user_filter { /** * Php filter definition */ const PHP_FILTER_READ = 'php://filter/read='; /** * Default PHP filter name for registration */ const FILTER_IDENTIFIER = 'go.source.transforming.loader'; /** * String buffer * * @var string */ protected $data = ''; /** * Identifier of filter * * @var string */ protected static $filterId; /** * Register current loader as stream filter in PHP * * @param string $filterId Identifier for the filter * @throws \RuntimeException If registration was failed */ public static function register($filterId = self::FILTER_IDENTIFIER) { if (!empty(self::$filterId)) { throw new \RuntimeException('Stream filter already registered'); } $result = stream_filter_register($filterId, __CLASS__); if (!$result) { throw new RuntimeException('Stream filter was not registered'); } self::$filterId = $filterId; } /** * {@inheritdoc} */ public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing || feof($this->stream)) { $consumed = strlen($this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } SourceTransformingLoader::register(); echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Return type of SourceTransformingLoader::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/bF4WL on line 53 <?php class SourceTransformingLoader extends php_user_filter { /** * Php filter definition */ const PHP_FILTER_READ = 'php://filter/read='; /** * Default PHP filter name for registration */ const FILTER_IDENTIFIER = 'go.source.transforming.loader'; /** * String buffer * * @var string */ protected $data = ''; /** * Identifier of filter * * @var string */ protected static $filterId; /** * Register current loader as stream filter in PHP * * @param string $filterId Identifier for the filter * @throws \RuntimeException If registration was failed */ public static function register($filterId = self::FILTER_IDENTIFIER) { if (!empty(self::$filterId)) { throw new \RuntimeException('Stream filter already registered'); } $result = stream_filter_register($filterId, __CLASS__); if (!$result) { throw new RuntimeException('Stream filter was not registered'); } self::$filterId = $filterId; } /** * {@inheritdoc} */ public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing || feof($this->stream)) { $consumed = strlen($this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } SourceTransformingLoader::register(); echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 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
<?php class SourceTransformingLoader extends php_user_filter { /** * Php filter definition */ const PHP_FILTER_READ = 'php://filter/read='; /** * Default PHP filter name for registration */ const FILTER_IDENTIFIER = 'go.source.transforming.loader'; /** * String buffer * * @var string */ protected $data = ''; /** * Identifier of filter * * @var string */ protected static $filterId; /** * Register current loader as stream filter in PHP * * @param string $filterId Identifier for the filter * @throws \RuntimeException If registration was failed */ public static function register($filterId = self::FILTER_IDENTIFIER) { if (!empty(self::$filterId)) { throw new \RuntimeException('Stream filter already registered'); } $result = stream_filter_register($filterId, __CLASS__); if (!$result) { throw new RuntimeException('Stream filter was not registered'); } self::$filterId = $filterId; } /** * {@inheritdoc} */ public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing || feof($this->stream)) { $consumed = strlen($this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } SourceTransformingLoader::register(); echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 <?php class SourceTransformingLoader extends php_user_filter { /** * Php filter definition */ const PHP_FILTER_READ = 'php://filter/read='; /** * Default PHP filter name for registration */ const FILTER_IDENTIFIER = 'go.source.transforming.loader'; /** * String buffer * * @var string */ protected $data = ''; /** * Identifier of filter * * @var string */ protected static $filterId; /** * Register current loader as stream filter in PHP * * @param string $filterId Identifier for the filter * @throws \RuntimeException If registration was failed */ public static function register($filterId = self::FILTER_IDENTIFIER) { if (!empty(self::$filterId)) { throw new \RuntimeException('Stream filter already registered'); } $result = stream_filter_register($filterId, __CLASS__); if (!$result) { throw new RuntimeException('Stream filter was not registered'); } self::$filterId = $filterId; } /** * {@inheritdoc} */ public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $this->data .= $bucket->data; } if ($closing || feof($this->stream)) { $consumed = strlen($this->data); $bucket = stream_bucket_new($this->stream, $this->data); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } SourceTransformingLoader::register(); echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 128217548 bytes
Process exited with code 1.
Output for 5.1.0 - 5.1.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 132957908 bytes
Process exited with code 1.
Output for 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 133243048 bytes
Process exited with code 1.
Output for 5.0.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 124768744 bytes
Process exited with code 1.
Output for 5.0.3
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 124880596 bytes
Process exited with code 1.
Output for 5.0.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 124831444 bytes
Process exited with code 1.
Output for 5.0.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 124826428 bytes
Process exited with code 1.
Output for 5.0.0
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39 FATAL: erealloc(): Unable to allocate 124866632 bytes
Process exited with code 1.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bF4WL on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bF4WL on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/bF4WL on line 8
Process exited with code 255.

preferences:
328.69 ms | 401 KiB | 398 Q