3v4l.org

run code in 300+ PHP versions simultaneously
<?php class values implements \Iterator{ private $_data = null; // array or object private $_keys = array(); private $_key = false; public function __construct($data = null){ if (null !== $data){ $this->_data = $data; } } // ------------ \Iterator implementation public function current(){ return $this->{$this->_key}; } public function key(){ return $this->_key; } public function next(){ $this->_key = \next($this->_keys); } public function rewind(){ $this->_keys = []; foreach ($this->_data as $k => $v){ $this->_keys[] = $k; } $this->_key = \reset($this->_keys); } public function valid(){ if (false === $this->_key){ return false; } return isset($this->{$this->_key}); } } $values = new values(new DateTime()); foreach($values as $k => $v) { var_dump($k, $v); }
Output for git.master_jit, git.master, rfc.property-hooks
Deprecated: Return type of values::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iRXke on line 13 Deprecated: Return type of values::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iRXke on line 19 Deprecated: Return type of values::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iRXke on line 16 Deprecated: Return type of values::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iRXke on line 29 Deprecated: Return type of values::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iRXke on line 22

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