3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ini_set('memory_limit', '-1'); $ary1 = array(); $ary2 = array(); $timeBegin = time(); for ($i = 0; $i <= 10000000; $i++) { $ary1[] = $i; } $timeEnd1 = time(); for ($i = 0; $i <= 10000000; $i++) { array_push($ary2, $i); } $timeEnd2 = time(); var_dump($timeBegin, $timeEnd1, $timeEnd2); echo 'first loop take ' . ($timeEnd1 - $timeBegin) . ' seconds' . PHP_EOL; echo 'second loop take ' . ($timeEnd2 - $timeEnd1) . ' seconds' . PHP_EOL;
based on JBk3l
Output for 7.0.0 - 7.0.9, 7.1.0 - 7.1.7, 7.2.0
Fatal error: Out of memory (allocated 136318976) (tried to allocate 268435464 bytes) in /in/sQ8cS on line 7 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 7.0.20, 7.1.10

Process exited with code 137.
Output for 5.6.28
Fatal error: Out of memory (allocated 259522560) (tried to allocate 32 bytes) in /in/sQ8cS on line 6
Process exited with code 255.
Output for 5.5.0 - 5.6.24
Fatal error: Out of memory (allocated 258998272) (tried to allocate 32 bytes) in /in/sQ8cS on line 6
Process exited with code 255.