Re: testing a variable
| From: | CPT John W. Holmes | Date: | Wed, 12 Nov 2003 16:50:56 +0000 |
| Subject: | Re: testing a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169302@lists.php.net to get a copy of this message | ||
From: "Adam Williams" <awilliam@mdah.state.ms.us>
> I need to test a variable to see if it contains a value or not, and if
> not, do something.
[snip]
> if ( !isset($var )
> { echo "do something";}
That's the correct way.
> What I am doing is checking a field in an sql table, and if the field is
> null, empty, etc... then do something. so what is the best way to check
> the field if its null, empty, etc...?
The variable might be set, yet empty, though. So you may want to add
if(!isset($var) || empty($var))
{ echo "do something"; }
---John Holmes...