[Fwd: Re: [PHP] Checking for Null Variables]

From: Date: Fri, 07 Mar 2003 17:36:21 +0000
Subject: [Fwd: Re: [PHP] Checking for Null Variables]
Groups: php.general 
Request: Send a blank email to php-general+get-138668@lists.php.net to get a copy of this message
quick way: if (!$field["name"]){ } else {} elegant ways (there will be many): if (empty($field["name"])){ // null or 0 } else {} if (is_null($field["name"])){ // null } else {} is_scalar() // string is_integer() // integer is_float() // float etc etc etc Christopher J. Crane wrote:
How do I check if a variable is blank or not. I am returning data from a MySQL database and if a field is empty I would like to do something different. I tried if($field["Name"] == "") { do this } else { do this } It does not work right. Actually, at one point, it was working in the exact opposite manner.


« previous php.general (#138668) next »