3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements ArrayAccess { protected $items = []; public function __construct(array $items) { $this->items = $items; } public function offsetExists($offset) { return array_key_exists($offset, $this->items); } public function offsetGet($offset) { return $this->items[$offset]; } public function offsetSet($key, $value) { if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } } public function offsetUnset($key) { unset($this->items[$key]); } } $arr = ['a' => null]; $coll = new Collection($arr); var_dump(isset($arr['a']), isset($coll['a']));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Collection::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/7Um54 on line 12 Deprecated: Return type of Collection::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/7Um54 on line 17 Deprecated: Return type of Collection::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/7Um54 on line 22 Deprecated: Return type of Collection::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/7Um54 on line 31 bool(false) bool(true)

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:
140.63 ms | 409 KiB | 5 Q