3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Reader extends IteratorIterator { private $is_first = true; public function current() { $this->is_first = false; return parent::current(); } public function valid() { $res = parent::valid(); if (!$res) $this->is_first = true; } public function rewind() { if (!$this->is_first) return; $this->is_first = true; parent::rewind(); } } $a = new Reader(new ArrayIterator(range(1, 10))); foreach ($a as $v) { echo $v . PHP_EOL; break; } foreach ($a as $v) { echo $v . PHP_EOL; break; } foreach ($a as $v) { echo $v . PHP_EOL; break; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Reader::rewind() should either be compatible with IteratorIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XumML on line 17 Deprecated: Return type of Reader::valid() should either be compatible with IteratorIterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XumML on line 11 Deprecated: Return type of Reader::current() should either be compatible with IteratorIterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XumML on line 6

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