3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyThing implements \ArrayAccess { protected $storage = []; public function __construct($values = array()) { foreach ($values as $name => $value) { $this->offsetSet($name, $value); } } public function offsetGet($name) { if (isset($this->storage[$name])) { return $this->storage[$name]; } } public function offsetSet($name, $value) { $this->storage[$name] = $value; } public function offsetUnset($name) { unset($this->storage[$name]); } public function offsetExists($name) { return isset($this->storage[$name]); } } function printArray(array $a) { print_r($a); } $thing = new MyThing(['foo' => 'bar']); printArray($thing);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyThing::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/B3ngF on line 26 Deprecated: Return type of MyThing::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/B3ngF on line 12 Deprecated: Return type of MyThing::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/B3ngF on line 18 Deprecated: Return type of MyThing::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/B3ngF on line 22 Fatal error: Uncaught TypeError: printArray(): Argument #1 ($a) must be of type array, MyThing given, called in /in/B3ngF on line 37 and defined in /in/B3ngF:32 Stack trace: #0 /in/B3ngF(37): printArray(Object(MyThing)) #1 {main} thrown in /in/B3ngF on line 32
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:
40.75 ms | 403 KiB | 8 Q