3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements ArrayAccess { public function offsetGet($offset){ return gettype($offset); } public function offsetSet($offset, $value){} public function offsetUnset($offset){} public function offsetExists($offset){} } $a = array('a', 'b', 'c'); $o = new Test(); $s = '1'; echo $o[1], "\n"; // 'integer' echo $o['1'], "\n"; // 'integer' !? echo $o[1.0], "\n"; // 'double' echo $o[$s], "\n"; // 'string' echo $o[$o], "\n"; // 'object' echo $a[1], "\n"; // 'integer' echo $a['1'], "\n"; // 'integer' echo $a[1.0], "\n"; // 'integer' echo $a[$s], "\n"; // 'integer' echo $a[$o], "\n"; // Warning: Illegal offset type
Output for git.master, git.master_jit
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/0BMYh on line 11 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/0BMYh on line 5 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/0BMYh on line 9 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/0BMYh on line 10 integer string double string object b b b b Fatal error: Uncaught TypeError: Illegal offset type in /in/0BMYh:28 Stack trace: #0 {main} thrown in /in/0BMYh on line 28
Process exited with code 255.
Output for rfc.property-hooks
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/0BMYh on line 11 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/0BMYh on line 5 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/0BMYh on line 9 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/0BMYh on line 10 integer string double string object b b b b Fatal error: Uncaught TypeError: Cannot access offset of type object on array in /in/0BMYh:28 Stack trace: #0 {main} thrown in /in/0BMYh on line 28
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:
50.53 ms | 402 KiB | 8 Q