3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test implements ArrayAccess { protected $_array = array(); public function offsetGet($name) { return $this->_array[$name]; } public function offsetSet($name,$value) { $this->_array[$name] = $value; } public function offsetUnset($name) { unset($this->_array[$name]); } public function offsetExists($name) { return isset($this->_array[$name]); } } $test = new test(); $test['foo'] = 'bar'; $test['baz'] = array('test','validator'); echo $test['baz'][1]; unset($test['baz']); var_dump($test);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of test::offsetExists($name) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/IssHV on line 13 Deprecated: Return type of test::offsetGet($name) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/IssHV on line 4 Deprecated: Return type of test::offsetSet($name, $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/IssHV on line 7 Deprecated: Return type of test::offsetUnset($name) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/IssHV on line 10 validatorobject(test)#1 (1) { ["_array":protected]=> array(1) { ["foo"]=> string(3) "bar" } }

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