#19229 [Opn->]: isset() handles NULL values incorrectly

From: Date: Wed, 04 Sep 2002 12:57:22 +0000
Subject: #19229 [Opn->]: isset() handles NULL values incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18409@lists.php.net to get a copy of this message
ID: 19229 Updated by: cynic@php.net Reported By: flying@dom.natm.ru -Status: Open +Status: Won't fix Bug Type: Scripting Engine problem Operating System: Windows 2000 PHP Version: 4.2.2 New Comment: ask rasmus. he'll tell you why this is the One True isset() Behavior. :) Previous Comments: ------------------------------------------------------------------------ [2002-09-04 07:24:51] flying@dom.natm.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:18:12] 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:06:13] flying@dom.natm.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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19229&edit=1

« previous php.bugs (#18409) next »