3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array_fill(0, 10000, 1); function by_reference(&$array) { echo "Inner by_reference: ", memory_get_usage(true), "\n"; foreach ($array as $var) { echo "Inner foreach: ", memory_get_usage(true), "\n"; break; } } function by_value($array) { echo "Inner by_value: ", memory_get_usage(true), "\n"; foreach ($array as $var) { echo "Inner foreach: ", memory_get_usage(true), "\n"; break; } } echo "Start: ", memory_get_usage(true), "\n"; by_reference($array); echo "After by_reference: ", memory_get_usage(true), "\n"; by_value($array); echo "After by_value: ", memory_get_usage(true), "\n";
Output for 7.0.0 - 7.1.0
Start: 2097152 Inner by_reference: 2097152 Inner foreach: 2097152 After by_reference: 2097152 Inner by_value: 2097152 Inner foreach: 2097152 After by_value: 2097152
Output for hhvm-3.12.0
Start: 464712 Inner by_reference: 464728 Inner foreach: 464728 After by_reference: 464728 Inner by_value: 464728 Inner foreach: 464728 After by_value: 464728
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.4.0 - 5.6.28
Start: 1310720 Inner by_reference: 1310720 Inner foreach: 1310720 After by_reference: 1310720 Inner by_value: 1310720 Inner foreach: 2359296 After by_value: 1835008
Output for 5.3.0 - 5.3.29
Start: 1835008 Inner by_reference: 1835008 Inner foreach: 1835008 After by_reference: 1835008 Inner by_value: 1835008 Inner foreach: 2883584 After by_value: 2097152
Output for 5.2.4 - 5.2.17
Start: 1310720 Inner by_reference: 1310720 Inner foreach: 1310720 After by_reference: 1310720 Inner by_value: 1310720 Inner foreach: 2359296 After by_value: 1572864
Output for 5.2.1 - 5.2.3
Start: 1310720 Inner by_reference: 1310720 Inner foreach: 1310720 After by_reference: 1310720 Inner by_value: 1310720 Inner foreach: 1310720 After by_value: 1310720
Output for 5.0.0 - 5.2.0
Start: Fatal error: Call to undefined function memory_get_usage() in /in/NkcOk on line 20
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Start: Fatal error: Call to undefined function: memory_get_usage() in /in/NkcOk on line 20
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Start: Fatal error: Call to undefined function: memory_get_usage() in /in/NkcOk on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Start: Fatal error: Call to undefined function: memory_get_usage() in /in/NkcOk on line 20