3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ar implements ArrayAccess { private $storage = []; private $offset = null; public function __construct(array $ar) { $this->storage = array_values($ar); $this->offset = 0; } public function offsetExists($offset) { return $offset <= count($this->storage); } public function offsetGet($offset) { return $this->storage[$offset]; } public function offsetSet($offset, $value) { $this->storage[$offset] = $value; } public function offsetUnset($offset) { unset($this->storage[$offset]); $this->storage = array_values($this->storage); } } $obj = new Ar([1,2,3,4,5,6,7]); var_dump(array_values($obj));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Ar::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Rh7kg on line 13 Deprecated: Return type of Ar::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Rh7kg on line 18 Deprecated: Return type of Ar::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Rh7kg on line 23 Deprecated: Return type of Ar::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Rh7kg on line 28 Fatal error: Uncaught TypeError: array_values(): Argument #1 ($array) must be of type array, Ar given in /in/Rh7kg:37 Stack trace: #0 /in/Rh7kg(37): array_values(Object(Ar)) #1 {main} thrown in /in/Rh7kg on line 37
Process exited with code 255.

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:
39.81 ms | 402 KiB | 8 Q