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?
I guess you expect that empty will return true only for NULL while actually whole set of values is considered to be "empty values"; from doc:
The following things are considered to be empty:
    * "" (an empty string)
    * 0 (0 as an integer)
    * 0.0 (0 as a float)
    * "0" (0 as a string)
    * NULL
    * FALSE
    * array() (an empty array)
    * var $var; (a variable declared, but without a value in a class)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With