Re: empty and isset

From: Date: Thu, 06 Feb 2003 16:51:56 +0000
Subject: Re: empty and isset
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-134642@lists.php.net to get a copy of this message
It's fairly easy. isset returns true if the VARIABLE itself exists, like if it's been declared, or set by a form. isset isn't checking the VALUE of the VARIABLE, just if it exists. In Jason's example below, isset returns false because the VARIABLE was never declared in some way, shape or form. Technically, it doesn't exist. empty returns true because the VARIABLE $doo, declared or not, has no VALUE. VARIABLE and VALUE...two different things. Jason Wong wrote:
On Thursday 06 February 2003 22:50, Mike.Kent@indystar.com wrote:
<input> of type text are set regardless of whether you have entered anything. Thus isset() returns true.
Actually, I believe it's not a matter of the input being set, but the fact that isset() returns true on an empty variable.
Try this: <?php if (isset($doo)) { print '$doo is set'; // does not get printed } if (empty($doo)) { print '$doo is empty'; // gets printed } ?>


« previous php.general (#134642) next »