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

From: Date: Wed, 04 Sep 2002 12:18:12 +0000
Subject: #19229 [Opn]: isset() handles NULL values incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18407@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 Bug Type: Scripting Engine problem Operating System: Windows 2000 PHP Version: 4.2.2 New Comment: 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. :) Previous Comments: ------------------------------------------------------------------------ [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 (#18407) next »