array_key_exists() doesn’t work on objects¶
array_key_exists() used to accept arrays and objects, and worked on them indistinctly.
Since PHP 8.0, array_key_exists() only works on arrays. Objects must be converted to arrays before usage.
PHP code¶
<?php
var_dump(array_key_exists('a', (object) ['a' => 1]));
?>
Before¶
true
After¶
Fatal error
PHP version change¶
This behavior was deprecated in Using array_key_exists() on objects is deprecated. Use isset() or property_exists()
This behavior changed in 8.0