ProAnswers.org

How do you validate empty fields in PHP?

How do you validate empty fields in PHP?

Following function can be used to test if variable or field is empty or not:

 

bool empty ( mixed var)

 

For Example

 

if (empty($var))

{

echo '$var is either 0, empty, or not set';

}

else

{

echo '$var is non empty';

}