3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyArrayIter implements Iterator { private $storage; public function __construct(array $a) { $storage = $a; } public function current() { return current($this->storage); } public function key() { return key($this->storage); } public function next() { next($this->storage); } public function rewind() { reset($this->storage); } public function valid() { return key($this->storage) !== null; } } $i = 1; $a = [1,2,$i,4,5]; $iter = new MyArrayIter($a); foreach($iter as &$v) { echo $v; } var_dump($a); var_dump($iter);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyArrayIter::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/nEOeE on line 7 Deprecated: Return type of MyArrayIter::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/nEOeE on line 13 Deprecated: Return type of MyArrayIter::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/nEOeE on line 10 Deprecated: Return type of MyArrayIter::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/nEOeE on line 19 Deprecated: Return type of MyArrayIter::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/nEOeE on line 16 Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in /in/nEOeE:28 Stack trace: #0 {main} thrown in /in/nEOeE on line 28
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.65 ms | 402 KiB | 8 Q