note 55966 added to function.empty
| From: | nahpeps at gmx dot de | Date: | Fri, 19 Aug 2005 10:14:07 +0000 |
| Subject: | note 55966 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93882@lists.php.net to get a copy of this message | ||
When using empty() on an object variable that is provided by the __get function, empty() will always
return true.
For example:
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
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55966
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55966&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55966&report=yes
Search -- http://master.php.net/manage/user-notes.php