Re: isset() VS if($var)

From: Date: Mon, 09 Apr 2001 13:19:08 +0000
Subject: Re: isset() VS if($var)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-47775@lists.php.net to get a copy of this message
Okey, thanks for your help Adam! Let us assume that we have a page which processes a form-submit: Ex: page with form <form method="post" name="myform" action="xyz.php3"> <input type="text" name="a">Write your name </form> Ex: page xyz.php3 if ($a) // I have seen such examples but what does it mean? Does it mean the same as isset-method? Thx! / Jeppe Adam Wright wrote: > > isset actually sees if the variable exists, and has been assigned a value > (where if is obviously checking for boolean truthfulness). Thus... > > $a = 0; > > if (isSet($a)) > print "A is set"; //This line will execute > > if (isSet($b)) > print "B is set"; //This line never will, as B has not been set to > anything every in this script > > And... > > if ($a) > print "A is true"; //This line won't execute, A is false > > if ($b) > print "B is true"; //Because B has never been set, $b = 0, and this will > never execute > > Hope that helps > > adamw > > ----- Original Message ----- > From: "Jesper Blomström" <jeppe@partitur.se> > To: <php-general@lists.php.net> > Sent: Monday, April 09, 2001 1:56 PM > Subject: [PHP] isset() VS if($var) > > > Hi! > > > > Is there any difference between writing: > > > > isset($my_var) > > > > and... > > > > if ($my_var) > > > > > > ?? > > > > > > Thanks! > > > > > > > > / Jesper Blomstroem > > > > -- > > Jesper Blomström > > jeppe@partitur.se > > Arbete: 08-566 280 08 > > Hem: 08-669 23 10 > > Mobil: 070-30 24 911 > > > > -- > > 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 > > > > -- Jesper Blomström jeppe@partitur.se Arbete: 08-566 280 08 Hem: 08-669 23 10 Mobil: 070-30 24 911

« previous php.general (#47775) next »