3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C extends ArrayObject { public function getArrayCopy() {return [__METHOD__];} public function getIterator() {yield __METHOD__;} public function serialize() {return serialize([__METHOD__]);} public function unserialize($data) {} public function offsetGet($key) {return __METHOD__;} public function offsetExists($key) {return TRUE;} public function offsetSet($key, $value) {} public function offsetUnset($key) {} } $o = new C(['x' => 5]); var_export([ 'json' => json_encode($o), '(array)' => (array) $o, '->x' => $o->x, ]);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Return type of C::offsetExists($key) should either be compatible with ArrayObject::offsetExists(mixed $key): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 9 Deprecated: Return type of C::offsetGet($key) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 8 Deprecated: Return type of C::offsetSet($key, $value) 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/rAc4K on line 10 Deprecated: Return type of C::offsetUnset($key) should either be compatible with ArrayObject::offsetUnset(mixed $key): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 11 Deprecated: Return type of C::getArrayCopy() should either be compatible with ArrayObject::getArrayCopy(): array, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 4 Deprecated: Return type of C::unserialize($data) should either be compatible with ArrayObject::unserialize(string $data): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 7 Deprecated: Return type of C::serialize() should either be compatible with ArrayObject::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 6 Deprecated: Return type of C::getIterator() should either be compatible with ArrayObject::getIterator(): Iterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 5 Warning: Undefined property: C::$x in /in/rAc4K on line 19 array ( 'json' => '{"x":5}', '(array)' => array ( 'x' => 5, ), '->x' => NULL, )
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 C::offsetExists($key) should either be compatible with ArrayObject::offsetExists(mixed $key): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 9 Deprecated: Return type of C::offsetGet($key) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 8 Deprecated: Return type of C::offsetSet($key, $value) 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/rAc4K on line 10 Deprecated: Return type of C::offsetUnset($key) should either be compatible with ArrayObject::offsetUnset(mixed $key): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 11 Deprecated: Return type of C::getArrayCopy() should either be compatible with ArrayObject::getArrayCopy(): array, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 4 Deprecated: Return type of C::unserialize($data) should either be compatible with ArrayObject::unserialize(string $data): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 7 Deprecated: Return type of C::serialize() should either be compatible with ArrayObject::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 6 Deprecated: Return type of C::getIterator() should either be compatible with ArrayObject::getIterator(): Iterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/rAc4K on line 5 Warning: Undefined property: C::$x in /in/rAc4K on line 19 array ( 'json' => '{"x":5}', '(array)' => array ( 'x' => 5, ), '->x' => NULL, )
Output for 8.0.0 - 8.0.30
Warning: Undefined property: C::$x in /in/rAc4K on line 19 array ( 'json' => '{"x":5}', '(array)' => array ( 'x' => 5, ), '->x' => NULL, )
Output for 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined property: C::$x in /in/rAc4K on line 19 array ( 'json' => '{"x":5}', '(array)' => array ( 'x' => 5, ), '->x' => NULL, )
Output for 7.3.32, 7.4.26
array ( 'json' => '{"x":5}', '(array)' => array ( 'x' => 5, ), '->x' => NULL, )

preferences:
171.15 ms | 401 KiB | 156 Q