Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Null With array_key_exists()

null is not accepted anymore as the first argument of the PHP native function array_key_exists(). Since PHP 8.5, null is not accepted anymore as a key in an array, so it is also not accepted with the function array_key_exists(), which checks if a key exists in an array.

PHP code

<?php

$array = [null => 1]; // silent error 
var_dump(array_key_exists(null, $array)); 

?>

Before

bool(true)

After

PHP Deprecated:  Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead

Deprecated: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead
bool(true)

PHP version change

This behavior changed in 8.5.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat