php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48364 unexpected isset return
Submitted: 2009-05-22 18:14 UTC Modified: 2009-05-22 19:39 UTC
From: clement dot hallet at af83 dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.9 OS: Mac OS X 10.5.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: clement dot hallet at af83 dot com
New email:
PHP Version: OS:

 

 [2009-05-22 18:14 UTC] clement dot hallet at af83 dot com
Description:
------------
Hi,

A call to the 'isset' function with a variable set to NULL returns FALSE.

As seen on a previous report bug (http://bugs.php.net/bug.php?id=6076), the return value should be TRUE.

Reproduce code:
---------------
$a = NULL;
var_dump(isset($a));

Expected result:
----------------
the return of isset($a) should be TRUE.

Actual result:
--------------
isset($a) returns FALSE

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-22 18:23 UTC] clement dot hallet at af83 dot com
That bug report is void. Have seen http://fr3.php.net/manual/en/function.isset.php

Maybe a change betweens versions ?
 [2009-05-22 18:26 UTC] pajoye@php.net
no bug > bogus :)
 [2009-05-22 18:38 UTC] clement dot hallet at af83 dot com
Sorry for the bad status :)

Please note that because of :
 $a = NULL;
 isset($a) -> FALSE
 is_null($b) -> TRUE (a notice happend)

It's impossible to test if a variable is _set_ to NULL :/
 [2009-05-22 19:19 UTC] pajoye@php.net
is_null
 [2009-05-22 19:39 UTC] clement dot hallet at af83 dot com
unfortunately no, because is_null on an unsetted variable returns TRUE.

What I try to say is that's impossible to test if a variable has been set AND it has been set to NULL.

For instance :

if($whatever) {
   //case 1
   $a = NULL;
} elseif($whateverelse) {
   // case 2
   $a = new SomeThing();
} else {
   // case 3
   // do things but no set the $a variable;
}

it's impossible after that to make a difference between cases 1 and 3, because (excepting for case 2):
 isset($a) will return FALSE in both cases
 is_null($a) will return TRUE in both cases


Sorry to insist, that way may have been declared as expected. But, I would like to make it understood before to consider it has a part of php.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 04:00:02 2025 UTC