3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class x { public $value; public function __construct($value) { $this->value = $value; } } $array = array(); for($i = 0; $i < 50000; $i++) { $array[] = md5('Hallo'); } $x = new x($array); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n"; unset($array); unset($x); var_dump(number_format(memory_get_usage(), 0, ',', '.')) . "\n"; var_dump(number_format(memory_get_usage(true), 0,',','.')) . "\n";
based on EqVLj
Output for 7.1.0
string(9) "5.651.864" string(9) "6.295.552" string(7) "350.512" string(9) "4.194.304"
Output for 7.0.0 - 7.0.14
string(9) "5.651.912" string(9) "6.295.552" string(7) "350.560" string(9) "4.194.304"
Output for hhvm-3.12.0
string(9) "6.291.456" string(9) "4.557.768" string(9) "6.291.456" string(7) "309.648"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
string(10) "10.348.984" string(10) "10.747.904" string(7) "224.200" string(7) "786.432"
Output for 5.5.24 - 5.5.35
string(10) "10.348.984" string(10) "10.747.904" string(7) "224.176" string(7) "786.432"
Output for 5.4.10 - 5.4.45
string(10) "10.349.472" string(10) "10.747.904" string(7) "224.688" string(7) "786.432"
Output for 5.4.0 - 5.4.9
string(10) "10.349.432" string(10) "10.747.904" string(7) "224.688" string(7) "786.432"
Output for 5.3.11 - 5.3.29
string(10) "10.754.800" string(10) "11.272.192" string(7) "629.808" string(9) "1.310.720"
Output for 5.3.0 - 5.3.10
string(10) "10.754.528" string(10) "11.272.192" string(7) "629.504" string(9) "1.310.720"
Output for 5.2.10 - 5.2.17
string(9) "9.813.000" string(10) "10.223.616" string(6) "87.768" string(7) "786.432"
Output for 5.2.7 - 5.2.9
string(9) "9.814.688" string(10) "10.223.616" string(7) "218.904" string(7) "786.432"
Output for 5.2.6
string(9) "9.815.008" string(10) "10.223.616" string(7) "219.224" string(7) "786.432"
Output for 5.2.3 - 5.2.5
string(9) "9.815.024" string(9) "9.961.472" string(7) "219.224" string(7) "786.432"
Output for 5.2.2
string(9) "9.812.928" string(9) "9.961.472" string(7) "217.120" string(7) "786.432"
Output for 5.2.1
string(9) "9.812.368" string(9) "9.961.472" string(7) "118.792" string(7) "786.432"
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/2EBN0 on line 17
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/2EBN0 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/2EBN0 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/2EBN0 on line 4
Process exited with code 255.