3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myIterator implements Iterator { private $position = 0; private $array = array( "firstelement", "secondelement", "lastelement", ); public function __construct() { $this->position = 0; } function rewind() { $this->position = 0; } function current() { return $this->array[$this->position]; } function key() { return $this->position; } function next() { ++$this->position; } function valid() { return isset($this->array[$this->position]); } } $it = new myIterator; var_dump($it->key()); var_dump(key($it)); ?>
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/4EZrT on line 19 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/4EZrT on line 27 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/4EZrT on line 23 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/4EZrT on line 31 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/4EZrT on line 15 int(0) Deprecated: key(): Calling key() on an object is deprecated in /in/4EZrT on line 38 string(20) "myIteratorposition"

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