Re: empty variable

From: Date: Mon, 20 Sep 2004 02:18:25 +0000
Subject: Re: empty variable
Groups: php.general 
Request: Send a blank email to php-general+get-197237@lists.php.net to get a copy of this message
if youdo if($var) { } and var doesnt exist at all, thats an error. if(isset($var)) { } will test to see if $var exists, but will not test the value of var, so $var could be blank... Jason "Pat" <patrick@arkeon.com> wrote: > > So, you have to know, first, what is your meaning of your empty variabe: > null, 0, "", array()? > > For example, "$var = 0;", empty($var) says true... but you? > > "Jason Davidson" <jdavidson@zworg.com> wrote in message > news:8752.1095640515@zworg.com... > > as suggeted the isset and empty functions are usefull, > > or if you know it may be set, but could be empty, how about just > > if($variable) { > > > > } > > > > that is the same as > > if($var == "") > > > > "Chris Mach" <cjmach@gto.net> wrote: > > > > > > What is the best way to determine if a variable is empty? > > > > > > I have a feeling there is a better way than the way I'm doing it now... > > > > > > if ($variable == "") > > > > > > > > > --- > > > Outgoing mail is certified Virus Free. > > > Checked by AVG anti-virus system (http://www.grisoft.com). > > > Version: 6.0.766 / Virus Database: 513 - Release Date: 18-Sep-2004 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#197237) next »