3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IncrementIterator implements iterator { protected $start; protected $end; protected $current; public function __construct($start, $end) { $this->start = $start; $this->end = $end; } public function rewind() { $this->current = $this->start; } public function valid() { return $this->current <= $this->end; } public function key() { return $this->current; } public function current() { return $this->current; } public function next() { $this->current++; } } $aIterator = new IncrementIterator(0, 26); $bIterator = new IncrementIterator(0, 26); $cIterator = new IncrementIterator(0, 26); $dIterator = new IncrementIterator(0, 26); $multipleIterator = new MultipleIterator(); $multipleIterator->attach($aIterator); $multipleIterator->attach($bIterator); $multipleIterator->attach($cIterator); $multipleIterator->attach($dIterator); foreach ($multipleIterator as $current) { var_dump($current); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of IncrementIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/FnWPo on line 24 Deprecated: Return type of IncrementIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/FnWPo on line 28 Deprecated: Return type of IncrementIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/FnWPo on line 20 Deprecated: Return type of IncrementIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/FnWPo on line 16 Deprecated: Return type of IncrementIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/FnWPo on line 12 Fatal error: Uncaught Error: Call to undefined method MultipleIterator::attach() in /in/FnWPo:39 Stack trace: #0 {main} thrown in /in/FnWPo on line 39
Process exited with code 255.

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:
47.12 ms | 402 KiB | 8 Q