note 124239 deleted from function.empty by cmb
| From: | cmb@php.net | Date: | Fri, 27 Sep 2019 16:05:54 +0000 |
| Subject: | note 124239 deleted from function.empty by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212363@lists.php.net to get a copy of this message | ||
Note Submitter: david dot bruchmann at gmail dot com
----
The comment by Janci is nonsense because in his code is attaching not-existing properties to his
class. If the properties are defined in the class empty() returns always the expected values.
In detail he never defined the public class-variables $empty and $notEmpty
class Registry
{
public $empty;
public $notEmpty;
protected $_items = array();
[...]
}
$registry = new Registry();
$registry->empty = '';
$registry->notEmpty = 'not empty';
var_dump(empty($registry->notExisting)); // true
var_dump(empty($registry->empty)); // true
var_dump(empty($registry->notEmpty)); // **false as expected**
$tmp = $registry->notEmpty;
var_dump(empty($tmp)); // false as expected