3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $foo = 'foo'; $range = range(1,100); foreach ($range as $i) { $$i = ''; } foreach ($range as $y) { $$y = ''; } var_dump($a = memory_get_usage()); foreach ($range as $i) { $$i = $foo; } var_dump($b = memory_get_usage()); foreach ($range as $y) { $$y &= $foo; } var_dump($c = memory_get_usage()); echo "Copy: " . ($b - $a) . "\n"; echo "Ref : " . ($c - $b) . "\n";
based on 2WUEh
Output for 7.1.0
int(365776) int(365808) int(369008) Copy: 32 Ref : 3200
Output for 7.0.3 - 7.0.14
int(365792) int(365824) int(369024) Copy: 32 Ref : 3200
Output for 7.0.0 - 7.0.2
int(365280) int(365312) int(368512) Copy: 32 Ref : 3200
Output for hhvm-3.12.0
int(2097152) int(2097152) int(2097152) Copy: 0 Ref : 0
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
int(250176) int(245560) int(253696) Copy: -4616 Ref : 8136
Output for 5.5.24 - 5.5.35
int(250176) int(245544) int(253680) Copy: -4632 Ref : 8136
Output for 5.4.10 - 5.4.45
int(250696) int(246064) int(254200) Copy: -4632 Ref : 8136
Output for 5.4.0 - 5.4.9
int(250168) int(245536) int(253672) Copy: -4632 Ref : 8136
Output for 5.3.11 - 5.3.29
int(659080) int(651256) int(659400) Copy: -7824 Ref : 8144
Output for 5.3.0 - 5.3.10
int(658776) int(650952) int(659096) Copy: -7824 Ref : 8144
Output for 5.2.10 - 5.2.17
int(115112) int(108080) int(115416) Copy: -7032 Ref : 7336
Output for 5.2.7 - 5.2.9
int(117536) int(117816) int(117912) Copy: 280 Ref : 96
Output for 5.2.3 - 5.2.6
int(117856) int(118136) int(118232) Copy: 280 Ref : 96
Output for 5.2.2
int(115776) int(115912) int(116048) Copy: 136 Ref : 136
Output for 5.2.1
int(114664) int(114896) int(115032) Copy: 232 Ref : 136
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/thUgD on line 11
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_usage() in /in/thUgD on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: memory_get_usage() in /in/thUgD on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_usage() in /in/thUgD on line 11