I am using this code using isset to check if empty:
if(!isset($this->objCodes[0]->SignupCode))$this->objCodes[0]->"NULL";
But it doesn’t work. Help?
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.
You might want to use empty to check if the value has a value that might be useless. If your SignupCode will never be an empty string (
""), 0, or another empty value, try this:The reason I normally use
empty()is because if I am importing from a database, the data I am looking for will always return true toisset()because it was set by the database. I’m more interested if it is null or an empty string, as that means there really isn’t anything of value in the variable.If you are loading values into your object like this:
You will always recieve a
trueto theisset()function when testing like this:Because the value is technically always going to be ‘set’
If you are actually trying to see if it isn’t set at all, try this: