Reputation: 1165
Maybe I'm asking a stupid question, but I can't understand this behavior:
<?php
$this->meeting->google_id = 'test';
$test = $this->meeting->google_id;
var_dump(empty($test));
var_dump(empty($this->meeting));
var_dump(empty($this->meeting->google_id));
?>
gives output:
bool(false) bool(false) bool(true)
Why the result of empty($this->meeting->google_id);
is true? And how should I check this property then?
Upvotes: 1
Views: 157
Reputation: 3769
Read here: http://www.php.net/manual/en/function.empty.php#93117
Basically, PHP magic methods resulting in unexpected behavior.
You can read/write to virtual members in a class if the class has a special __get
magic method. The actual value, however, cannot be checked by the __isset
magic method (which is what empty
uses), because it's not an explicit member of the class.
Upvotes: 3