php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62724 isset returns false but array_key_exists returns true (int keys)
Submitted: 2012-08-02 09:36 UTC Modified: 2012-08-02 09:47 UTC
From: max at kriegt dot es Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.4.5 OS: Debian 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: max at kriegt dot es
New email:
PHP Version: OS:

 

 [2012-08-02 09:36 UTC] max at kriegt dot es
Description:
------------
Hi,

recently realized that isset not returning the same result as array_key_exists 
does for int-Keys.

Test script:
---------------
<?php
$foo = array(null);

var_dump( isset($foo[0]), array_key_exists(0, $foo) );

Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(false)
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-02 09:43 UTC] keithm at aoeex dot com
This is not a bug.  From the manual page on isset:
"Determine if a variable is set and is not NULL."

In your example, $foo[0] is null which is why isset returns false.
 [2012-08-02 09:46 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2012-08-02 09:46 UTC] aharvey@php.net
What Keith said. :)
 [2012-08-02 09:47 UTC] max at kriegt dot es
Hm - misinterpreted the function. :/
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 09:01:33 2025 UTC