Re: empty variables from a form
| From: | 1LT John W. Holmes | Date: | Wed, 05 Feb 2003 19:43:33 +0000 |
| Subject: | Re: empty variables from a form | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134479@lists.php.net to get a copy of this message | ||
> > > how would you test for an empty (unused) variable from a form..
> > > i have a phone number split into 3 different vairiables and want to
test
> > to
> > > see if they were used in the form before displaying either the phone
> > number
> > > itself or just leaving it out of the display... what code would be
good
> to
> > > test it with.. the variables are $ac2 $ext2 and $num2
> >
> > Use the isset() function:
> >
> > if(isset($ac2)) and
> > if(isset($ext2)) and
> > if(isset($num2)) { do something }
> > else { do something else }
That's not a good idea if your trying to check for an empty variable. An
empty text box, when submitted, will still be set and pass isset(). You
should use empty() is that's really what you're looking for.
---John Holmes...