3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements ArrayAccess { public function offsetGet($x) { var_dump($x); } public function offsetExists($x) { var_dump($x); } public function offsetSet($x, $y) { var_dump($x); } public function offsetUnset($x) { var_dump($x); } } $foo = new Foo(); echo "$foo[0]"; echo "$foo[1]"; echo "$foo[00]";
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Deprecated: Return type of Foo::offsetExists($x) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 7 Deprecated: Return type of Foo::offsetGet($x) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 4 Deprecated: Return type of Foo::offsetSet($x, $y) 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/qU9E9 on line 10 Deprecated: Return type of Foo::offsetUnset($x) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/qU9E9 on line 13 int(0) int(1) string(2) "00"
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
int(0) int(1) string(2) "00"

preferences:
163.95 ms | 403 KiB | 219 Q