note 124239 added to function.empty
| From: | david dot bruchmann at gmail dot com | Date: | Fri, 27 Sep 2019 15:26:08 +0000 |
| Subject: | note 124239 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212362@lists.php.net to get a copy of this message | ||
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
----
Server IP: 208.43.231.9
Probable Submitter: 195.138.250.34 (proxied: 36.71.225.244)
----
Manual Page -- http://php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/124239
Del: integrated -- https://master.php.net/note/delete/124239/integrated
Del: useless -- https://master.php.net/note/delete/124239/useless
Del: bad code -- https://master.php.net/note/delete/124239/bad+code
Del: spam -- https://master.php.net/note/delete/124239/spam
Del: non-english -- https://master.php.net/note/delete/124239/non-english
Del: in docs -- https://master.php.net/note/delete/124239/in+docs
Del: other reasons-- https://master.php.net/note/delete/124239
Reject -- https://master.php.net/note/reject/124239
Search -- https://master.php.net/manage/user-notes.php