3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Maps implements Iterator { protected $key, $data; public function __construct() { $key = new stdClass; $value = new stdClass; $key->long = 1.1; $key->lat = 42.0; $value = "New York, NY"; $this->data[] = array($key, $value); $key->long = 2.2; $key->lat = 24.0; $value = "Rochester, NY"; $this->data[] = array($key, $value); } public function key() { return $this->data[0]; } public function current() { return $this->data[1]; } public function next() { next($this->data); } public function valid() { return key($this->data) !== null; } public function rewind() { reset($this->data); } } $maps = new Maps; foreach($maps as $keyMap => $locationMap) { var_dump($keyMap, $locationMap); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Maps::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/5oYNB on line 33 Deprecated: Return type of Maps::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/5oYNB on line 38 Deprecated: Return type of Maps::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/5oYNB on line 28 Deprecated: Return type of Maps::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/5oYNB on line 43 Deprecated: Return type of Maps::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/5oYNB on line 48 array(2) { [0]=> object(stdClass)#2 (2) { ["long"]=> float(2.2) ["lat"]=> float(24) } [1]=> string(12) "New York, NY" } array(2) { [0]=> object(stdClass)#2 (2) { ["long"]=> float(2.2) ["lat"]=> float(24) } [1]=> string(13) "Rochester, NY" } array(2) { [0]=> object(stdClass)#2 (2) { ["long"]=> float(2.2) ["lat"]=> float(24) } [1]=> string(12) "New York, NY" } array(2) { [0]=> object(stdClass)#2 (2) { ["long"]=> float(2.2) ["lat"]=> float(24) } [1]=> string(13) "Rochester, NY" }

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.53 ms | 405 KiB | 8 Q