It’s like this:
$var = $obj->data->field;
echo $var; // works, I get the value of 'field'
if(empty($var)) echo '$var is empty!'; // I get this message too. wtf?
What’s the problem here? Why does empty() return true?
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.
My guess:
$obj->data->field“is” an object and the class does not implement the __isset() method as you’d need it in order to use empty() this way.What does
print?
self-contained example to demonstrate the effect:
prints