#48468 [Csd]: empty function confusing
| From: | bjori@php.net | Date: | Thu, 04 Jun 2009 09:40:41 +0000 |
| Subject: | #48468 [Csd]: empty function confusing | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2344@lists.php.net to get a copy of this message | ||
ID: 48468
Updated by: bjori@php.net
Reported By: heikki dot leppanen at extendeddisc dot com
Status: Closed
Bug Type: Translation problem
Operating System: windows
PHP Version: 5.2.5
Assigned To: bjori
New Comment:
__isset() is triggered by calling isset() or empty() on inaccessible
members.
http://no.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members
And soon this will be on the isset(), empty() and unset() pages:
http://news.php.net/php.doc.cvs/4114
Previous Comments:
------------------------------------------------------------------------
[2009-06-04 09:26:36] heikki dot leppanen at extendeddisc dot com
For me it looks like __get() is called. In my experience the only place
where this is not working is empty().
class A {
var $vars = array('a'=>'aa', 'b'=>'bb');
function __get ($name) {
return $this->vars[$name];
}
}
$x = new A();
if (empty($x->a))
echo "this is empty<br>";
else
echo "this in not empty<br>";
echo "x->a::$x->a<br>";
Result is
this is empty // This is wrong
x->a::aa // This is correct
------------------------------------------------------------------------
[2009-06-04 09:09:03] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
The __isset() overloading method is called, not __get()
------------------------------------------------------------------------
[2009-06-04 08:50:06] heikki dot leppanen at extendeddisc dot com
OK, now the syntax is correct. This is only example from my code I
wrote to demonstrate the confusing with empty()
class A {
var $vars = array('a'=>'aa', 'b'=>'bb');
function __get ($name) {
return $this->vars[$name];
}
}
$x = new A();
if (empty($x->a))
echo "this is empty<br>";
else
echo "this in not empty<br>";
------------------------------------------------------------------------
[2009-06-04 08:20:03] bjori@php.net
That is incorrect too, where are you seeing this?
------------------------------------------------------------------------
[2009-06-04 08:08:33] heikki dot leppanen at extendeddisc dot com
It should be like this:
var $vars = array{'a'=>'aa', 'b'=>'bb'};
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/48468
--
Edit this bug report at http://bugs.php.net/?id=48468&edit=1