3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Get 10mb of data from /dev/zero try { $infp = fopen('/dev/zero', 'r'); $data = fread($infp, 1024 * 1024 * 1); } finally { if (isset($infp) && $infp !== false) { echo "closing!"; fclose($infp); } } write_data($data); echo "Peak memory usage: ", number_format(memory_get_peak_usage()), " bytes\n"; /** * Bad example of how to write some data to /dev/null */ function write_data($data) { $outfp = fopen('/dev/null', 'w'); fwrite($outfp, $data); fwrite($outfp, "\n"); fclose($outfp); }
Output for 7.3.0rc3
Warning: fopen(): open_basedir restriction in effect. File(/dev/zero) is not within the allowed path(s): (/tmp:/in:/etc) in /in/0Qnh4 on line 6 Warning: fopen(/dev/zero): failed to open stream: Operation not permitted in /in/0Qnh4 on line 6 Warning: fread() expects parameter 1 to be resource, bool given in /in/0Qnh4 on line 7 Warning: fopen(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/tmp:/in:/etc) in /in/0Qnh4 on line 25 Warning: fopen(/dev/null): failed to open stream: Operation not permitted in /in/0Qnh4 on line 25 Warning: fwrite() expects parameter 1 to be resource, bool given in /in/0Qnh4 on line 26 Warning: fwrite() expects parameter 1 to be resource, bool given in /in/0Qnh4 on line 27 Warning: fclose() expects parameter 1 to be resource, bool given in /in/0Qnh4 on line 28 Peak memory usage: 425,920 bytes
Output for 7.3.0beta1
closing!Peak memory usage: 1,450,392 bytes
Output for 7.3.0alpha1
closing!Peak memory usage: 1,450,416 bytes
Output for 7.2.6
Warning: fopen(): open_basedir restriction in effect. File(/dev/zero) is not within the allowed path(s): (/tmp:/in) in /in/0Qnh4 on line 6 Warning: fopen(/dev/zero): failed to open stream: Operation not permitted in /in/0Qnh4 on line 6 Warning: fread() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 7 Warning: fopen(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/tmp:/in) in /in/0Qnh4 on line 25 Warning: fopen(/dev/null): failed to open stream: Operation not permitted in /in/0Qnh4 on line 25 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 26 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 27 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 28 Peak memory usage: 421,600 bytes
Output for 7.2.0
closing!Peak memory usage: 1,446,552 bytes
Output for 7.1.20
Warning: fopen(): open_basedir restriction in effect. File(/dev/zero) is not within the allowed path(s): (/tmp:/in) in /in/0Qnh4 on line 6 Warning: fopen(/dev/zero): failed to open stream: Operation not permitted in /in/0Qnh4 on line 6 Warning: fread() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 7 Warning: fopen(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/tmp:/in) in /in/0Qnh4 on line 25 Warning: fopen(/dev/null): failed to open stream: Operation not permitted in /in/0Qnh4 on line 25 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 26 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 27 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 28 Peak memory usage: 384,576 bytes
Output for 7.1.10
closing!Peak memory usage: 1,410,008 bytes
Output for 7.0.0 - 7.1.7
Warning: fopen(): open_basedir restriction in effect. File(/dev/zero) is not within the allowed path(s): (/tmp/) in /in/0Qnh4 on line 6 Warning: fopen(/dev/zero): failed to open stream: Operation not permitted in /in/0Qnh4 on line 6 Warning: fread() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 7 Warning: fopen(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/tmp/) in /in/0Qnh4 on line 25 Warning: fopen(/dev/null): failed to open stream: Operation not permitted in /in/0Qnh4 on line 25 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 26 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 27 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 28 Peak memory usage: 384,576 bytes
Output for hhvm-3.15.4
closing!Peak memory usage: 4,194,304 bytes
Output for 5.6.0 - 5.6.30
Warning: fopen(): open_basedir restriction in effect. File(/dev/zero) is not within the allowed path(s): (/tmp/) in /in/0Qnh4 on line 6 Warning: fopen(/dev/zero): failed to open stream: Operation not permitted in /in/0Qnh4 on line 6 Warning: fread() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 7 Warning: fopen(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/tmp/) in /in/0Qnh4 on line 25 Warning: fopen(/dev/null): failed to open stream: Operation not permitted in /in/0Qnh4 on line 25 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 26 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 27 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/0Qnh4 on line 28 Peak memory usage: 227,432 bytes