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->lat, $keyMap->long, $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/qJtRi 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/qJtRi 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/qJtRi 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/qJtRi 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/qJtRi on line 48 Warning: Attempt to read property "lat" on array in /in/qJtRi on line 58 Warning: Attempt to read property "long" on array in /in/qJtRi on line 58 Warning: Array to string conversion in /in/qJtRi on line 58 string(9) ", , Array" Warning: Attempt to read property "lat" on array in /in/qJtRi on line 58 Warning: Attempt to read property "long" on array in /in/qJtRi on line 58 Warning: Array to string conversion in /in/qJtRi on line 58 string(9) ", , Array"

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