Re: distinguish between null variable and unset variable

From: Date: Thu, 22 Jan 2009 20:17:30 +0000
Subject: Re: distinguish between null variable and unset variable
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-287031@lists.php.net to get a copy of this message
Daniel Brown wrote: > On Thu, Jan 22, 2009 at 15:11, Shawn McKenzie <nospam@mckenzies.net> wrote: >> Or something like this (dunno, just brainstorming): >> >> function setornull(&$var) >> { >> if (!isset($var)) { >> return false; >> } >> elseif (is_null($var)) { >> return null; >> } >> return true; >> } > > Unfortunately, neither solution would work. isset() will return > FALSE even for an instantiated and explicitly-defined NULL variable. > Yes, damn it! -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#287031) next »