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(){ 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 Jn8em
Output for 5.1.0 - 5.4.34
Fatal error: Method x::__unset() must take exactly 1 argument in /in/PBjJR on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function gc_enable() in /in/PBjJR 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/PBjJR 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/PBjJR 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/PBjJR on line 5
Process exited with code 255.