3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function benchmarkMemory(callable $function, $args=null) { $memory = memory_get_peak_usage(); $result = is_array($args)? call_user_func_array($function, $args): call_user_func_array($function); return [ 'memory' => memory_get_peak_usage() - $memory ]; } var_dump(benchmarkMemory('str_repeat', ['test',1E4])); gc_collect_cycles(); var_dump(benchmarkMemory('str_repeat', ['test',1E3]));
Output for 7.1.0
array(1) { ["memory"]=> int(5008) } array(1) { ["memory"]=> int(0) }
Output for 7.0.0 - 7.0.14
array(1) { ["memory"]=> int(5384) } array(1) { ["memory"]=> int(0) }
Output for 5.5.0 - 5.6.28
array(1) { ["memory"]=> int(35984) } array(1) { ["memory"]=> int(0) }
Output for 5.4.0 - 5.4.45
array(1) { ["memory"]=> int(36064) } array(1) { ["memory"]=> int(0) }
Output for 5.2.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0ifv8 on line 8
Process exited with code 255.
Output for 5.1.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected '[' in <b>/in/0ifv8</b> on line <b>8</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected '[' in <b>/in/0ifv8</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting ')' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting ')' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `')'' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255.