3v4l.org

run code in 300+ PHP versions simultaneously
<?php class obj implements \ArrayAccess , \IteratorAggregate { public function __construct() { foreach(array("one" => 1, "two" => 2, "three" => 3) as $offset => $value) $this->{$offset} = $value; } public function offsetSet($offset, $value) { $this->{$offset} = $value; } public function offsetExists($offset) { return isset($this->{$offset}); } public function offsetUnset($offset) { unset($this->{$offset}); } public function offsetGet($offset) { return isset($this->{$offset}) ? $this->{$offset} : null; } function getIterator() { return new \ArrayIterator($this); } } $obj = new obj; foreach($obj as $offset => $value) unset($obj[$offset]); print_r($obj); foreach(get_object_vars($obj) as $offset => $value) unset($obj[$offset]); print_r($obj);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of obj::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fDFbU on line 10 Deprecated: Return type of obj::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fDFbU on line 16 Deprecated: Return type of obj::offsetSet($offset, $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/fDFbU on line 7 Deprecated: Return type of obj::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fDFbU on line 13 Deprecated: Return type of obj::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fDFbU on line 19 Deprecated: Creation of dynamic property obj::$one is deprecated in /in/fDFbU on line 5 Deprecated: Creation of dynamic property obj::$two is deprecated in /in/fDFbU on line 5 Deprecated: Creation of dynamic property obj::$three is deprecated in /in/fDFbU on line 5 obj Object ( [two] => 2 ) obj Object ( )

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.39 ms | 405 KiB | 8 Q