3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php gc_enable(); class x { public $value; public function __construct($value) { $this->value = $value; } public function __unset($arg){ echo "Working"; unset($this->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 PBjJR
Output for 7.1.0
string(9) "5.652.664" string(9) "6.295.552" string(7) "351.288" string(9) "4.194.304"
Output for 7.0.0 - 7.0.14
string(9) "5.652.712" string(9) "6.295.552" string(7) "351.336" string(9) "4.194.304"
Output for hhvm-3.12.0
string(9) "6.291.456" string(9) "4.558.392" string(9) "6.291.456" string(7) "310.272"
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
string(10) "10.350.232" string(10) "10.747.904" string(7) "225.472" string(7) "786.432"
Output for 5.5.24 - 5.5.35
string(10) "10.350.232" string(10) "10.747.904" string(7) "225.448" string(7) "786.432"
Output for 5.4.10 - 5.4.45
string(10) "10.350.784" string(10) "10.747.904" string(7) "225.952" string(7) "786.432"
Output for 5.4.0 - 5.4.9
string(10) "10.350.784" string(10) "10.747.904" string(7) "225.960" string(7) "786.432"
Output for 5.3.11 - 5.3.29
string(10) "10.756.568" string(10) "11.272.192" string(7) "631.584" string(9) "1.310.720"
Output for 5.3.0 - 5.3.10
string(10) "10.756.504" string(10) "11.272.192" string(7) "631.448" string(9) "1.572.864"
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function gc_enable() in /in/mDHr0 on line 2
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/mDHr0 on line 5
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/mDHr0 on line 5
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/mDHr0 on line 5
Process exited with code 255.