3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjArray implements ArrayAccess { private $data; public function toArray() { return $this->data; } public function offsetSet($key, $value) { var_dump($key, $value); $this->data[$key] = $value; } public function offsetGet($key) { return $this->data[$key]; } public function offsetUnset($key) { unset($this->data[$key]); } public function offsetExists($key) { return isset($this->data[$key]); } } $arr = new ObjArray; $arr[0] = 1; $arr[] = 2; var_dump($arr->toArray());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ObjArray::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ZUfHZ on line 28 Deprecated: Return type of ObjArray::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ZUfHZ on line 18 Deprecated: Return type of ObjArray::offsetSet($key, $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/ZUfHZ on line 12 Deprecated: Return type of ObjArray::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/ZUfHZ on line 23 int(0) int(1) NULL int(2) array(2) { [0]=> int(1) [""]=> int(2) }

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