note 55966 deleted from function.empty by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 09:24:27 +0000 |
| Subject: | note 55966 deleted from function.empty by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213362@lists.php.net to get a copy of this message | ||
Note Submitter: nahpeps at gmx dot de
----
When using empty() on an object variable that is provided by the __get function, empty() will always
return true.
For example:
<?php
class foo {
public function __get($var) {
if ($var == "bar") {
return "bar";
}
}
}
$object_foo = new foo();
echo '$object_foo->bar is ' . $object_foo->bar;
if (empty($object_foo->bar)) {
echo '$object_foo->bar seems to be empty';
}
?>
produces the following output:
$object_foo->bar is bar
$object_foo->bar seems to be empty