3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Obj implements ArrayAccess { public $container = [ "one" => 1, "two" => 2, "three" => 3, ]; public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset): bool { return isset($this->container[$offset]); } public function offsetUnset($offset): void { unset($this->container[$offset]); } public function offsetGet($offset): mixed { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } $o = new Obj(); if (array_key_exists('a', $o)) { echo "has-a"; } else { echo "NO-a"; }
Output for git.master_jit, git.master, rfc.property-hooks
Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, Obj given in /in/S0GNX:32 Stack trace: #0 {main} thrown in /in/S0GNX 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:
27.07 ms | 405 KiB | 5 Q