Better way to check variable for null or empty string?

// Function for basic field validation (present and neither empty nor only white space
function IsNullOrEmptyString($str){
    return ($str === null || trim($str) === '');
}

Old post but someone might need it as I did ;)

if (strlen($str) == 0){
do what ever
}

replace $str with your variable. NULL and "" both return 0 when using strlen.