3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }

preferences:
35.5 ms | 402 KiB | 5 Q