Re: Testing if variable was set

From: Date: Thu, 17 May 2001 09:14:48 +0000
Subject: Re: Testing if variable was set
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53192@lists.php.net to get a copy of this message
Jordan, http://www.php.net/manual/en/function.isset.php When you do: if ($var) you are saying if $var is boolean true which is not what you say you want: > Hi, > If I want to test if a variable exists (or has been passed) then I just do: > Mohamed~ Jordan Elver wrote: > > Hi, > If I want to test if a variable exists (or has been passed) then I just do: > > if($var) { > // variable is here > } > > But I've noticed that a lot of people do: > > if(isset($var)) { > // variable is here > } > > What's the difference and which is the best way? > > TIA, > > Jord > > -- > Jordan Elver > while (!asleep()) sheep++; > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#53192) next »