|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79803 array_key_exists not returning bool
Submitted: 2020-07-07 09:52 UTC Modified: 2020-07-07 10:13 UTC
From: marekvikartovsky at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Arrays related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-07-07 09:52 UTC] marekvikartovsky at gmail dot com
From manual page:


if I am calling array_key_exists on NULL by mistake, the function should return bool FALSE, not NULL. I understand that it shows me a warning, but it also should return bool value as in documentation.

I tested it on PHP version 7.1.33 and 7.4.7

Test script:
var_dump(array_key_exists('test', NULL));

Expected result:
By documentation I am expecting to return a bool value, not NULL or you should return an exception, not warning.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-07 10:06 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-07-07 10:06 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2020-07-07 10:13 UTC] marekvikartovsky at gmail dot com
Thanks for your time, I didnt seen, that there is wrote "This behaviour should not be relied upon, and care should be taken to ensure that array is an array."

Thank you,

Have a nice day!
 [2020-07-07 10:13 UTC]
Moreover, the behaviour has been changed for PHP 8 so that an exception is thrown if the second argument is not an array.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 18:05:45 2022 UTC