3v4l.org

run code in 300+ PHP versions simultaneously
<?php class bar implements ArrayAccess { public $fields = []; /** * __construct * * @param mixed $eventInfo * @return void */ public function __construct($eventInfo) { // parent::__construct(); foreach ($eventInfo as $name => $value) { $this[$name] = $value; } } /** * getId * * @return void */ public function getId() { return $this; } /** * offsetExists * * @param mixed $name * @return void */ public function offsetExists($name) { return isset($this->fields[$name]); } /** * offsetGet * * @param mixed $name * @return void */ public function offsetGet($name) { return isset($this->fields[$name]) ? $this->fields[$name] : null; } /** * offsetSet * * @param mixed $name * @param mixed $value * @return void */ public function offsetSet($name, $value) { $this->fields[$name] = $value; } /** * offsetUnset * * @param mixed $name * @return void */ public function offsetUnset($name) { unset($this->fields[$name]); } } $eventInfo = ["name" => "A", "type" => "Programmer", "action" => "success"]; print_r((new bar($eventInfo))->getId());
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of bar::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/X83NX on line 39 Deprecated: Return type of bar::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/X83NX on line 49 Deprecated: Return type of bar::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/X83NX on line 61 Deprecated: Return type of bar::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/X83NX on line 72 bar Object ( [fields] => Array ( [name] => A [type] => Programmer [action] => success ) )

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:
42.61 ms | 1640 KiB | 4 Q