3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyArrayObject extends ArrayObject{ function __construct($input=[]){ parent::__construct($input,ArrayObject::ARRAY_AS_PROPS); } function offsetSet($x,$v){ echo "offsetSet('{$x}')\n"; return parent::offsetSet($x,$v); } function offsetGet($x){ echo "offsetGet('{$x}')\n"; return parent::offsetGet($x); } function __get($x){ echo "__get('{$x}')\n"; } function __set($x,$v){ echo "__set('{$x}')\n"; } function offsetExists($x){ echo "offsetExists('{$x}')\n"; return parent::offsetExists($x); } } $x=new MyArrayObject; $x->hello=5; $x['hi']=10; $x['hello']++; @$x->a->b=7; $x->a->b++;
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyArrayObject::offsetExists($x) should either be compatible with ArrayObject::offsetExists(mixed $key): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/DJH6M on line 20 Deprecated: Return type of MyArrayObject::offsetGet($x) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/DJH6M on line 10 Deprecated: Return type of MyArrayObject::offsetSet($x, $v) should either be compatible with ArrayObject::offsetSet(mixed $key, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/DJH6M on line 6 offsetSet('hello') offsetSet('hi') offsetGet('hello') Notice: Indirect modification of overloaded element of MyArrayObject has no effect in /in/DJH6M on line 28 offsetGet('a') Fatal error: Uncaught Error: Attempt to assign property "b" on null in /in/DJH6M:29 Stack trace: #0 {main} thrown in /in/DJH6M on line 29
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:
69.69 ms | 402 KiB | 8 Q