3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getMem() { return memory_get_usage(true) / 1024; } $array = range(1, 1000000); shuffle($array); $mem = getMem(); $string = compress($array); echo 'You used : ', getMem() - $mem, ' Kb', PHP_EOL; function compress($array) { return gzdeflate(base64_encode(implode(',', $array)), 9); } function uncompress($data) { return explode(',', base64_decode(gzinflate($data))); } file_put_contents('demo', $string); $uncompress = uncompress($string); for ($i = 0; $i < 100; $i++) { $test = rand(0, 1000000 - 1); if ($array[$test] != $uncompress[$test]) { die('You failed!!!'); } } echo 'You Win', PHP_EOL; echo date('Y-m-d H:i:s'), PHP_EOL;
Output for 7.0.33, 7.1.24 - 7.1.25, 7.2.11 - 7.2.13, 7.3.0

Process exited with code 137.
Output for 7.0.0 - 7.0.32, 7.1.0 - 7.1.23, 7.2.0 - 7.2.10
You used : 3872 Kb Warning: file_put_contents(): open_basedir restriction in effect. File(demo) is not within the allowed path(s): (/tmp:/in:/etc) in /in/hUkrO on line 23 Warning: file_put_contents(demo): failed to open stream: Operation not permitted in /in/hUkrO on line 23 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 16777224 bytes) in /in/hUkrO on line 20
Process exited with code 255.
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.38
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/hUkrO on line 8
Process exited with code 255.
Output for 5.2.2 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/hUkrO on line 8
Process exited with code 255.
Output for 5.2.1
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/hUkrO on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/hUkrO on line 5
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_usage() in /in/hUkrO on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: memory_get_usage() in /in/hUkrO on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_usage() in /in/hUkrO on line 5

preferences:
174.87 ms | 401 KiB | 287 Q