<?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]";
echo "$foo[-0]";
echo "$foo[-1]";
//echo "$foo[-00]";
//echo "$foo[-001]";
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/r699v 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/r699v 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/r699v 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/r699v on line 13
int(0)
int(1)
string(2) "00"
string(2) "-0"
int(-1)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
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/r699v 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/r699v 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/r699v 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/r699v on line 13
int(0)
int(1)
string(2) "00"
string(2) "-0"
int(-1)
Parse error: syntax error, unexpected '-', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /in/r699v on line 23
Process exited with code 255.