3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { public $x; public function __construct($self) { $this->x = $self; } } Class Bar { static function create(){ $b = new Bar(); $b->f = new Foo($b->get()); } function get(){ $self = $this; return function() use ($self) {return $self;}; } } echo memory_get_usage(), "\n"; for ($i = 0; $i < 1000; ++$i) { Bar::create(); } echo gc_collect_cycles() . "\n"; echo memory_get_usage(), "\n";
Output for 7.1.0
350072 3000 374680
Output for 7.0.0 - 7.0.14
350080 3000 375064
Output for 5.6.0 - 5.6.28
224536 3000 421592
Output for 5.5.0 - 5.5.38
224520 3000 421560
Output for 5.4.0 - 5.4.45
225024 3000 422064
Output for 5.3.11 - 5.3.29
630144 3000 827264
Output for 5.3.9 - 5.3.10
629840 3000 826960
Output for 5.3.1 - 5.3.8
629840 0 2291000
Output for 5.3.0
629840 0 2283048
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/IG5F5 on line 21
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/IG5F5 on line 21
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/IG5F5 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/IG5F5 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/IG5F5 on line 5
Process exited with code 255.