php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19229 isset() handles NULL values incorrectly
Submitted: 2002-09-04 07:06 UTC Modified: 2002-09-04 09:32 UTC
From: flying at dom dot natm dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.2 OS: Windows 2000
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: flying at dom dot natm dot ru
New email:
PHP Version: OS:

 

 [2002-09-04 07:06 UTC] flying at dom dot natm dot ru
Take a look at the following example:
<?php
$array = array('foo',null,'bar');
foreach($array as $key=>$value)
    echo "Set: ".((isset($array[$key]))?'yes':'no')."\nValue: ".serialize($value)."\n\n";
?>

It returns following result:

Set: yes
Value: s:3:"foo";

Set: no
Value: N;

Set: yes
Value: s:3:"bar";

 As you can see - isset() returns FALSE for array item, containing NULL value, but it should return TRUE because array item itself is set and have value.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-04 07:18 UTC] cynic@php.net
this is one of a few *very* controversial bugs/features (choose your flavor) in php. as much as lots of people would like this changed, it won't be.
use array_key_exists() for arrays, and i wish you luck with scalars. :)

 [2002-09-04 07:24 UTC] flying at dom dot natm dot ru
Hmm... I wonder about what (really serious) reason can be for keep it as it is now? 
 And it works in this way not only with arrays, usual variables, containing NULLs are also "not set"....
 [2002-09-04 07:57 UTC] cynic@php.net
ask rasmus. he'll tell you why this is the One True isset() Behavior. :)


 [2002-09-04 09:32 UTC] sniper@php.net
There's nothing to fix as this is not any bug -> bogus.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 19:00:01 2026 UTC