3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myIterator implements Iterator { public $bar = [5, 4, 3, 2, 1]; public function valid() { return $this->key() !== null; } public function current() { return current($this->bar); } public function key() { return key($this->bar); } public function next() { return next($this->bar); } public function rewind() { rewind($this->bar); } } $it = new myIterator(); while ($it->valid()) { var_dump($it->current()); $it->next(); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of myIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/bmUvv on line 11 Deprecated: Return type of myIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/bmUvv on line 19 Deprecated: Return type of myIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/bmUvv on line 15 Deprecated: Return type of myIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/bmUvv on line 7 Deprecated: Return type of myIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/bmUvv on line 23 int(5) int(4) int(3) int(2) int(1)

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:
139.3 ms | 409 KiB | 5 Q