3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo extends ArrayObject { 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.3.0 - 7.3.1
391776 4000 416384
Output for 7.2.0 - 7.2.13
387936 4000 412544
Output for 7.1.25
351360 4000 375968
Output for 7.1.0, 7.1.7
351432 4000 376040
Output for 7.1.5 - 7.1.6
351888 4000 376496
Output for 7.0.0 - 7.0.4, 7.0.6 - 7.0.20
351440 4000 376424
Output for 7.0.5
351472 4000 376456
Output for 5.6.28
232624 4000 429704
Output for 5.6.7 - 5.6.21
232624 0 1821808
Output for 5.5.24 - 5.5.35
232592 0 1821744
Output for 5.4.10 - 5.4.45
232896 0 1814024
Output for 5.4.0 - 5.4.9
232896 0 1814080
Output for 5.3.15 - 5.3.29
638208 0 2699424
Output for 5.3.11 - 5.3.14
638208 0 2699488
Output for 5.3.9 - 5.3.10
637904 0 2699104
Output for 5.3.1 - 5.3.8
637904 0 2691072
Output for 5.3.0
637904 0 2675088
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/1V635 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/1V635 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/1V635 on line 5
Process exited with code 255.
Output for 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/1V635 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/1V635 on line 5
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/FFJmm on line 5
Process exited with code 255.

preferences:
140.6 ms | 401 KiB | 191 Q