note 55966 modified in function.empty by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 22:08:29 +0000 |
| Subject: | note 55966 modified in function.empty by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147306@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:
<?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
--was--
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
http://php.net/manual/en/function.empty.php