3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php call_user_func(function(){ echo 'val_val' . PHP_EOL; $a = range(1, 100000); $m = memory_get_usage(); $b = $a; $c = $b; echo ' memory usage: ' . number_format(memory_get_usage() - $m) . PHP_EOL; }); call_user_func(function(){ echo 'ref_val' . PHP_EOL; $a = range(1, 100000); $m = memory_get_usage(); $b = &$a; $c = $b; echo ' memory usage: ' . number_format(memory_get_usage() - $m) . PHP_EOL; }); call_user_func(function(){ echo 'val_ref' . PHP_EOL; $a = range(1, 100000); $m = memory_get_usage(); $b = $a; $c = &$b; echo ' memory usage: ' . number_format(memory_get_usage() - $m) . PHP_EOL; }); call_user_func(function(){ echo 'ref_ref' . PHP_EOL; $a = range(1, 100000); $m = memory_get_usage(); $b = &$a; $c = &$b; echo ' memory usage: ' . number_format(memory_get_usage() - $m) . PHP_EOL; });
Output for 7.0.0 - 7.1.0
val_val memory usage: 0 ref_val memory usage: 24 val_ref memory usage: 24 ref_ref memory usage: 24
Output for hhvm-3.10.0 - 3.12.0
val_val memory usage: 0 ref_val memory usage: 0 val_ref memory usage: 0 ref_ref memory usage: 0
Output for 5.3.1 - 5.3.29, 5.5.0 - 5.6.28
val_val memory usage: 48 ref_val memory usage: 9,848,776 val_ref memory usage: 9,848,776 ref_ref memory usage: 48
Output for 5.3.0, 5.4.0 - 5.4.45
val_val memory usage: 48 ref_val memory usage: 9,848,800 val_ref memory usage: 9,848,800 ref_ref memory usage: 48
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/fNRDq on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/fNRDq on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/fNRDq on line 2
Process exited with code 255.