php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40791 isset - null - is_null
Submitted: 2007-03-13 10:01 UTC Modified: 2007-03-13 11:00 UTC
From: mauthi at gmx dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.1 OS:
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: mauthi at gmx dot net
New email:
PHP Version: OS:

 

 [2007-03-13 10:01 UTC] mauthi at gmx dot net
Description:
------------
In my function (see code below) i tried to return the value of an array at position "key"
If the value is null, i want to return null - it works as shown in the code - but if the key is not set - my function also returns "null"!

So i can't find a solution to differ "null" or "not set"!



Reproduce code:
---------------
$a = array();
// case 1:
$a["key"] = null;
// end case 1

// case 2:
// end case 2

if (isset($a["key"]))
{
	return $a["key"];
}
else
{
	if (is_null($a["key"])
            return null;
        else
            return "key not set!";
}

Expected result:
----------------
case 1:
null
case 2:
"key not set!"

Actual result:
--------------
case 1:
null
case 2:
null 
>> Undefined Index: key in XXX (in log file)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-13 11:00 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 14:01:31 2025 UTC