I have checked many questions on same topic on stack overflow but still I am not able to do it. Please excuse if I am missing something very trivial.
What I need to check is …whether a variable does not contain empty(or multiple whitespaces) string ?
but when I use like $a==NULL, it will fail for 0 which is a valid string.
when I use is_null() or $a===NULL, then it will only check for "" but not if user input contain multiple white space characters like " ".
I guess may be some kind of regular expression may help here but I am not sure. Please help me.
Thanks.
Use
trimto remove whitespace characters:Remember to use the identical comparison operator whenever possible to avoid truthiness issues (such as
"0"acting as a false value).