3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php fclose(STDIN); fclose(STDOUT); fclose(STDERR); $STDIN = fopen('/dev/null', 'r'); $STDOUT = fopen('php://stdout', 'wb'); $STDERR = fopen('/dev/null', 'wb'); class TestFilterClass { function filter($in, $out) { while (true) { $bucket = stream_bucket_make_writeable($in); if (is_object($bucket)) { $bucket->data = sprintf('[%s] %s', __METHOD__, $bucket->data); stream_bucket_append($out, $bucket); } break; } return PSFS_PASS_ON; } } if (stream_filter_register('TestFilter', 'TestFilterClass')) { $handle = stream_filter_append($STDOUT, 'TestFilter'); if (is_resource($handle)) { fwrite($STDOUT, 'hello world' . PHP_EOL); // ok echo 'hello world' . PHP_EOL; // nope stream_filter_remove($handle); } }
Output for 5.2.3 - 5.6.28, 7.0.0 - 7.1.0
Output for hhvm-3.12.0

Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0 - 5.2.2
Notice: Use of undefined constant STDIN - assumed 'STDIN' in /in/LsTIB on line 3 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 3 Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /in/LsTIB on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 4 Notice: Use of undefined constant STDERR - assumed 'STDERR' in /in/LsTIB on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 5 [TestFilterClass::filter] hello world hello world
Output for 5.0.0 - 5.0.5
Notice: Use of undefined constant STDIN - assumed 'STDIN' in /in/LsTIB on line 3 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 3 Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /in/LsTIB on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 4 Notice: Use of undefined constant STDERR - assumed 'STDERR' in /in/LsTIB on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 5
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant STDIN - assumed 'STDIN' in /in/LsTIB on line 3 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 3 Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /in/LsTIB on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 4 Notice: Use of undefined constant STDERR - assumed 'STDERR' in /in/LsTIB on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 5 Fatal error: Call to undefined function: stream_filter_register() in /in/LsTIB on line 30
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Notice: Use of undefined constant STDIN - assumed 'STDIN' in /in/LsTIB on line 3 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 3 Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /in/LsTIB on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 4 Notice: Use of undefined constant STDERR - assumed 'STDERR' in /in/LsTIB on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 5 Fatal error: Call to undefined function: stream_filter_register() in /in/LsTIB on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant STDIN - assumed 'STDIN' in /in/LsTIB on line 3 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 3 Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /in/LsTIB on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 4 Notice: Use of undefined constant STDERR - assumed 'STDERR' in /in/LsTIB on line 5 Warning: fclose(): supplied argument is not a valid stream resource in /in/LsTIB on line 5 Fatal error: Call to undefined function: stream_filter_register() in /in/LsTIB on line 30