3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cars implements Iterator { private $pointer = 0; private $array = array(); public function __construct() { $this->pointer = 0; } public function addCar($car) { array_push($this->array, $car); } function rewind() { $this->pointer = 0; } function current() { return $this->array[$this->pointer]; } function key() { return $this->pointer; } function next() { ++$this->pointer; } public function valid() { return isset($this->array[$this->pointer]); } } $car = new Cars; $car->addCar("Volvo"); $car->addCar("BMW"); $car->addCar("Mercedes"); foreach ($car as $key => $value) { echo $key . ": " . $value . "<br />"; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Cars::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UPZOs on line 15 Deprecated: Return type of Cars::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UPZOs on line 21 Deprecated: Return type of Cars::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UPZOs on line 18 Deprecated: Return type of Cars::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UPZOs on line 24 Deprecated: Return type of Cars::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/UPZOs on line 12 0: Volvo<br />1: BMW<br />2: Mercedes<br />

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