quote:
Originally posted by Stigmata
I normally use (!$variable)?
Why are we talking about PHP in a JScript thread?
Anyway, these are equivalent with one major difference...
if(!$variable) { }
if(empty($variable)) { }
If $variable has not been set, the first will generate a warning message (which you'll only see if your
error_reporting level includes
E_NOTICE).
PHP Notice: Undefined variable: variable
So if you're sure a variable has been set, just use !$variable. If not, use empty().
Note: empty() is just a shorter way of doing this...
if(!isset($variable) || !$variable) { }