3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function delta() { static $lastmem; $delta = memory_get_peak_usage() - $lastmem; if ($lastmem == 0) $delta = 0; $lastmem = memory_get_peak_usage(); return $delta; } $a=range(1, 500); for($x=0;$x<sizeof($a);$x++) { $a[$x]++; } var_dump('for loop and increment delta:'.delta()); foreach($a as $k=>$v) { $a[$k]++; } var_dump('foreach loop and increment delta: '.delta());
Output for 7.1.0
string(30) "for loop and increment delta:0" string(38) "foreach loop and increment delta: 5288"
Output for 7.0.0 - 7.0.14
string(30) "for loop and increment delta:0" string(38) "foreach loop and increment delta: 5304"
Output for hhvm-3.12.0
string(30) "for loop and increment delta:0" string(35) "foreach loop and increment delta: 0"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.8 - 5.6.28
string(30) "for loop and increment delta:0" string(39) "foreach loop and increment delta: 72520"
Output for 5.4.0 - 5.5.35
string(30) "for loop and increment delta:0" string(39) "foreach loop and increment delta: 72472"
Output for 5.3.0 - 5.3.29
string(30) "for loop and increment delta:0" string(39) "foreach loop and increment delta: 72432"
Output for 5.2.1 - 5.2.17
string(30) "for loop and increment delta:0" string(39) "foreach loop and increment delta: 68248"
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_peak_usage() in /in/W6Yp8 on line 5
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/W6Yp8 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/W6Yp8 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/W6Yp8 on line 5