3v4l.org

run code in 300+ PHP versions simultaneously
<?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.4.0
390304 3000 414912
Output for 7.3.0 - 7.3.12
390456 3000 415064
Output for 7.2.17 - 7.2.25
386576 3000 411184
Output for 7.2.0
386616 3000 411224
Output for 7.1.26 - 7.1.33
350000 3000 374608
Output for 7.1.0, 7.1.7
350072 3000 374680
Output for 7.1.5 - 7.1.6
350488 3000 375096
Output for 7.0.0 - 7.0.4, 7.0.6 - 7.0.20
350080 3000 375064
Output for 7.0.5
350112 3000 375096
Output for 5.6.8 - 5.6.28
224536 3000 421592
Output for 5.5.24 - 5.5.35
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.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/6YQJL 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/6YQJL 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/6YQJL on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/6YQJL 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/6YQJL on line 5
Process exited with code 255.

preferences:
149.24 ms | 401 KiB | 205 Q