3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo "Init: ".memory_get_usage() . PHP_EOL . PHP_EOL; $test = $test2 = array(); $i = 0; while ($i++ < 100000) { $test[] = $i; $test2[] = $i; } // test loop 1 echo "Test 1: ".memory_get_usage() . PHP_EOL; foreach ($test as $k => $v) { unset($test[$k]); echo memory_get_usage() . PHP_EOL . PHP_EOL; break; } // test loop 2 echo "Test 2: ".memory_get_usage() . PHP_EOL; foreach ($test2 as $k => &$v) { unset($test2[$k]); echo memory_get_usage() . PHP_EOL . PHP_EOL; break; }
Output for 7.1.0
Init: 348456 Test 1: 8745448 12943928 Test 2: 8745448 8745496
Output for 7.0.0 - 7.0.14
Init: 348480 Test 1: 8745472 12943952 Test 2: 8745472 8745520
Output for 5.6.0 - 5.6.28
Init: 219872 Test 1: 24718008 34566872 Test 2: 24718104 24718000
Output for 5.5.0 - 5.5.38
Init: 219872 Test 1: 24717816 34566680 Test 2: 24717936 24717848
Output for 5.4.10 - 5.4.45
Init: 220392 Test 1: 24718512 34567376 Test 2: 24718608 24718520
Output for 5.4.0 - 5.4.9
Init: 219864 Test 1: 24717848 34566712 Test 2: 24717976 24717888
Output for 5.3.11 - 5.3.29
Init: 625008 Test 1: 25123032 34971912 Test 2: 25123160 25123072
Output for 5.3.0 - 5.3.10
Init: 624704 Test 1: 25122720 34971600 Test 2: 25122872 25122784
Output for 5.2.10 - 5.2.17
Init: 83608 Test 1: 23782888 33631760 Test 2: 23782704 23782624
Output for 5.2.7 - 5.2.9
Init: 84320 Test 1: 23785704 33634672 Test 2: 23914008 23913896
Output for 5.2.6
Init: 84640 Test 1: 23786000 33634968 Test 2: 23914256 23914144
Output for 5.2.3 - 5.2.5
Init: 84640 Test 1: 23785864 33634832 Test 2: 23914152 23914040
Output for 5.2.2
Init: 82568 Test 1: 23783816 33632776 Test 2: 23912096 23911960
Output for 5.2.1
Init: 82568 Test 1: 23782768 33631720 Test 2: 23813664 33631768
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/nSmSZ on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/nSmSZ on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/nSmSZ on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/nSmSZ on line 21
Process exited with code 255.