3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Items implements \Iterator { private $items = []; private $index = 0; public function current() { return $this->items[$this->index]; } public function next() { $this->index++; } public function valid() { return isset($this->items[$this->index]); } public function key() { return $this->index; } public function rewind() { $this->index = 0; } public function add($item) { $this->items[] = $item; } public function remove($index) { unset($this->items[$index]); } } //------------------- $items = new Items(); $items->add('foo'); $items->add('bar'); $items->add('baz'); $items->remove(0); // Expected that the loop would start with the first index of "1" // but it doesn't output anything foreach($items as $item) { echo $item."\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Items::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UXF3A on line 9 Deprecated: Return type of Items::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UXF3A on line 13 Deprecated: Return type of Items::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UXF3A on line 21 Deprecated: Return type of Items::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UXF3A on line 17 Deprecated: Return type of Items::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UXF3A on line 25

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:
71.58 ms | 403 KiB | 8 Q