Is there a better way besides isset() or empty() to test for an empty variable?
Is there a better way besides isset() or empty() to test for an empty
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends upon the context.
isset()will ONLY return true when the value of the variable is notNULL(and thereby the variable is at least defined).empty()will return true when the value of the variable is deemed to be an “empty” value, typically this means0,"0",NULL,FALSE,array()(an empty array) and""(an empty string), anything else is not empty.Some examples