3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); class MyArray implements ArrayAccess { public $value; public function __construct($value = null) { $this->value = $value; } public function &offsetGet($offset) { var_dump(__METHOD__); if (!isset($this->value[$offset])) { $this->value[$offset] = null; } return $this->value[$offset]; } public function offsetExists($offset) { var_dump(__METHOD__); return isset($this->value[$offset]); } public function offsetSet($offset, $value) { var_dump(__METHOD__); $this->value[$offset] = $value; } public function offsetUnset($offset) { var_dump(__METHOD__); $this->value[$offset] = null; } } $record = new MyArray([ 'foo' => [ 'bar' => 'baz' ] ]); var_dump(isset($record['foo']['bar'])); var_dump(isset($record['hello']['world']));
Output for git.master_jit, git.master, rfc.property-hooks
Deprecated: Return type of MyArray::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/vOeG0 on line 25 Deprecated: Return type of & MyArray::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/vOeG0 on line 14 Deprecated: Return type of MyArray::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/vOeG0 on line 32 Deprecated: Return type of MyArray::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/vOeG0 on line 39 string(21) "MyArray::offsetExists" string(18) "MyArray::offsetGet" bool(true) string(21) "MyArray::offsetExists" bool(false)

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:
18.62 ms | 404 KiB | 8 Q