[FX.php List] if ( $var != '' ) OR if ( !empty($var) ) -- gen'l php recommendations?

Joel Shapiro jsfmp at earthlink.net
Mon Jul 24 17:55:18 MDT 2006


Hi all

General PHP question here.  Apologies if I shouldn't post non-FX  
questions.

When checking if a variable is not empty, are there reasons to choose  
one of these over the other?  (or are there preferable options still?)

if ( $var != '' )
{
	# code...
}


if ( !empty($var) )
{
	# code...
}

note: it seems that isset($var) will not give me what I want, since  
it can return true even if $var is set to empty

TIA,
-Joel


More information about the FX.php_List mailing list