3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements ArrayAccess { private $data = array(); /** Array Access */ public function offsetExists($offset) { return isset($this->data[$offset]); } public function &offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $value) { $this->data[$offset] = $value; } public function offsetUnset($offset) { unset($this->data[$offset]); } } class Test2 extends ArrayObject { public function &offsetGet($offset) { $t =& parent::offsetGet($offset); return $t; } } $t = new Test(); $t['test'] = array(1,2,3,4); echo serialize($t)."\n"; $t['test'][] = 5; echo serialize($t)."\n"; $t = new Test2(); $t['test'] = array(1,2,3,4); echo serialize($t)."\n"; $t['test'][] = 5; echo serialize($t)."\n";
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of & Test2::offsetGet($offset) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qdJEZ on line 29 Deprecated: Return type of Test::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/qdJEZ on line 7 Deprecated: Return type of & Test::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/qdJEZ on line 12 Deprecated: Return type of Test::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/qdJEZ on line 17 Deprecated: Return type of Test::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/qdJEZ on line 22 O:4:"Test":1:{s:10:"Testdata";a:1:{s:4:"test";a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;}}} O:4:"Test":1:{s:10:"Testdata";a:1:{s:4:"test";a:5:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;}}} O:5:"Test2":4:{i:0;i:0;i:1;a:1:{s:4:"test";a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;}}i:2;a:0:{}i:3;N;} Notice: Only variables should be assigned by reference in /in/qdJEZ on line 31 O:5:"Test2":4:{i:0;i:0;i:1;a:1:{s:4:"test";a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;}}i:2;a:0:{}i:3;N;}

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:
34.32 ms | 405 KiB | 8 Q