3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection { public $fixedArray; public function __construct(SplFixedArray $splFixedArray) { $this->fixedArray = $splFixedArray; } public function getSum() { $sum = 0; $arr = $this->fixedArray; foreach ($arr as $item) { $sum += $item; } return $sum; } } $spl = SplFixedArray::fromArray([0, 1, 2]); $collection = new Collection($spl); $collArr = $collection->fixedArray; $i = 0; foreach ($collArr as $item) { echo '-- iteration: ' . $i . ', sum: ' . $collection->getSum() . PHP_EOL; $i++; } echo 'Expected 3 iterations, executed ' . $i . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
-- iteration: 0, sum: 3 -- iteration: 1, sum: 3 -- iteration: 2, sum: 3 Expected 3 iterations, executed 3

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

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


preferences:
65.8 ms | 401 KiB | 8 Q