3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new \ArrayObject(); $object['foo'] = null; var_dump($object); echo "\nobject array access:\n"; var_dump(isset($object['foo'])); var_dump(array_key_exists('foo', $object)); var_dump(property_exists($object, 'foo')); if (isset($object['foo']) || array_key_exists('foo', $object)) { var_dump($object['foo']); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.2
object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { ["foo"]=> NULL } } object array access: bool(false) Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, ArrayObject given in /in/16e5v:11 Stack trace: #0 {main} thrown in /in/16e5v on line 11
Process exited with code 255.
Output for 7.4.0 - 7.4.33
object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { ["foo"]=> NULL } } object array access: bool(false) Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /in/16e5v on line 11 bool(true) bool(false) Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /in/16e5v on line 14 NULL
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { ["foo"]=> NULL } } object array access: bool(false) bool(true) bool(false) NULL

preferences:
144.47 ms | 410 KiB | 5 Q