3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Obj implements ArrayAccess { private $container = array(); public function __construct() { $this->container = array( "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; } } $obj = new Obj; $obj[] = 3; $obj[] = 4; print_r($obj);
Output for git.master, git.master_jit, rfc.property-hooks
Obj Object ( [container:Obj:private] => Array ( [one] => 1 [two] => 2 [three] => 3 [0] => 3 [1] => 4 ) )

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.41 ms | 401 KiB | 8 Q