3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements Iterator { private $ar = [ 1, 2, 3 ]; public function toArray() { return $this->ar; } public function rewind() { reset( $this->ar ); } public function valid() { return !is_null( $this->key() ); } public function key() { return key( $this->ar ); } public function current() { return current( $this->ar ); } public function next() { next( $this->ar ); } } $t = new Test; foreach( $t as $key => $value ) { echo "orig: $key: $value\n"; foreach( $t->toArray() as $copyKey => $copyValue ) { echo " copy: $copyKey: $copyValue\n"; } echo "----\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Test::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/l96fW on line 24 Deprecated: Return type of Test::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/l96fW on line 28 Deprecated: Return type of Test::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/l96fW on line 20 Deprecated: Return type of Test::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/l96fW on line 16 Deprecated: Return type of Test::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/l96fW on line 12 orig: 0: 1 copy: 0: 1 copy: 1: 2 copy: 2: 3 ---- orig: 1: 2 copy: 0: 1 copy: 1: 2 copy: 2: 3 ---- orig: 2: 3 copy: 0: 1 copy: 1: 2 copy: 2: 3 ----

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