FYI, isset() will return true for an empty variable.  You use isset() only
when you expect there to be no variable.  But for a hard coded HTML form the
variable will *always* be set (except in the case of check boxes) even if
thas no value.  So your only options are to use empty() or test the string
against the litteral expression.

if($myvar == '');
..or..
if(empty($myvar));

-Kevin

----- Original Message -----
From: "Sunfire" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 05, 2003 12:40 PM
Subject: Re: [PHP] empty variables from a form


> tnx will try that my other code looked something like that but it didnt
> work.. probably had the (and ) in the wrong places... i set it up as the
> whole statement as 1 if statement not 3 different ones..
>
>
> ----- Original Message -----
> From: "Erich Beyrent" <[EMAIL PROTECTED]>
> To: "Sunfire" <[EMAIL PROTECTED]>
> Sent: Wednesday, February 05, 2003 1:54 PM
> Subject: Re: [PHP] empty variables from a form
>
>
> > > hi..
> > >
> > > 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 }
> >
> > -Erich-
> >
> >
> >
> >
> >
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to