3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIter implements Iterator { private $a; private $key = 0; public function __construct(array $a) { $this->a = array_values($a); } public function key() { return $this->key; } public function rewind() { $this->key = 0; } public function valid() { echo __METHOD__, PHP_EOL; return isset($this->a[$this->key]); } public function next() { echo __METHOD__, PHP_EOL; $this->key++; } public function current() { echo __METHOD__, PHP_EOL; return $this->a[$this->key]; } } $ilist = new MyIter(array('A', 'B', 'C', 'D')); foreach ($ilist as $var) { echo "var = $var\n"; echo "current = ", print_r(current($ilist), true), "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyIter::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/a7NtE on line 35 Deprecated: Return type of MyIter::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/a7NtE on line 29 Deprecated: Return type of MyIter::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/a7NtE on line 13 Deprecated: Return type of MyIter::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/a7NtE on line 23 Deprecated: Return type of MyIter::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/a7NtE on line 18 MyIter::valid MyIter::current var = A current = Deprecated: current(): Calling current() on an object is deprecated in /in/a7NtE on line 45 Array ( [0] => A [1] => B [2] => C [3] => D ) MyIter::next MyIter::valid MyIter::current var = B current = Deprecated: current(): Calling current() on an object is deprecated in /in/a7NtE on line 45 Array ( [0] => A [1] => B [2] => C [3] => D ) MyIter::next MyIter::valid MyIter::current var = C current = Deprecated: current(): Calling current() on an object is deprecated in /in/a7NtE on line 45 Array ( [0] => A [1] => B [2] => C [3] => D ) MyIter::next MyIter::valid MyIter::current var = D current = Deprecated: current(): Calling current() on an object is deprecated in /in/a7NtE on line 45 Array ( [0] => A [1] => B [2] => C [3] => D ) MyIter::next MyIter::valid

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:
44.81 ms | 405 KiB | 8 Q