Empty or null strings

Can any one help i seem to be struggling

i have 3 post vars $hash $to $message

how would i throw errors up if they were either null or empty?

ended up using the following


if ($hash == "")
  {
  echo $hashempty;
  exit();
  }
elseif ($to == "")
  {
  echo $numberempty;
  exit();
  }
elseif ($message == "")
  {
  echo $messageempty;
  exit();
  }
else
  {
  // Continue
  }

although this is not checking if the vars have been set it still prevents empty strings.

You can use the empty() function - it will return true if the variable is unset, or is empty (see the manual page for a list of conditions which count as empty).

To check whether a variable is null, use the following if condition:


$var = NULL;
if($var === NULL){

}
else{

}

Alternatively, the function is_null($var) also checks whether a variable is null. To verify if a string is empty, simply call empty($string) and it will return a boolean true/false value.