Re: if(isset($a)) vs if($a)

From: Date: Sat, 15 Sep 2001 21:14:41 +0000
Subject: Re: if(isset($a)) vs if($a)
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-67465@lists.php.net to get a copy of this message
On Sat, 15 Sep 2001 13:20:59 -0700, CC Zona wrote: >In article <1972676115.20010915090000@naverex.kiev.ua>, > ok@naverex.kiev.ua (Andrew Perevodchik) wrote: > >> JD> isset checks to see if the $a variable has >> JD> been set, ie, if it exists. if($a) checks for >> JD> the truthood of $a, meaning, if it has a >> JD> non-zero, non-null/empty-string value, then >> JD> its true, else, false. >> >> ... and if it's not set at all it returns a >> warning unless you use "@" :( > >Or change the error_reporting level, or turn off display_errors >(okay, >technically the warning is still happening in the latter case, but >IIRC >that's also true of @--both simply suppress the *reporting* of the >report >rather than the *occurance* of the error). > >This is why it's best to do multiple checks and choose them >carefully. Ex: > >if(isset($) and !empty($a) and !$a) this is the same as if(!empty($a)) >or > >if(isset($) and $a===FALSE) this is the same as if(empty($a))

« previous php.general (#67465) next »