Ckecking for empty strings in PHP

How do I check if a string variable is empty using PHP? My variable is $name. Presently, I have a statement that looks like this:
if ($name == "") {...} else {...}
but if I enter one or more blank spaces into $name, control passes to the else part. I want to block this and make sure the else part is carried out only if $name is not empty.
Thank you.
Who is Participating?
if (empty(trim($name))
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.