3v4l.org

run code in 200+ PHP versions simultaneously
<?php class Foo { private $bar = []; public function fill($limit = 100) { for ($i = 0; $i < $limit; $i++) { $this->bar[] = mt_rand($i, $limit); } } public function getEvenCounter() : Countable { return function () implements Countable { $counter = 0; foreach ($this->bar as $value) { if ($value % 2 === 0) $counter++; } return $counter; }; } public function getOddCounter() : Countable { return function () implements Countable { $counter = 0; foreach ($this->bar as $value) { if ($value % 2 !== 0) { $counter++; } } return $counter; }; } } $foo = new Foo(); $even = $foo->getEvenCounter(); $odd = $foo->getOddCounter(); $it = 0; while (++$it<10) { $foo->fill(50); var_dump( count($even), count($odd)); } ?>

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Parse error: syntax error, unexpected 'implements' (T_IMPLEMENTS), expecting '{' in /in/b4AWq on line 12
Process exited with code 255.

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page