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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 06:01:32 2024 UTC