|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-04 06:44 UTC] heikki dot leppanen at extendeddisc dot com
Description:
------------
class A {
var $vars = {'a'=>'aa', 'b'=>'bb'};
function __get ($name) {
return $this->vars[$name];
}
}
$x = new A();
if (empty($this->a))
echo "this is empty");
else
echo "this in not empty");
For me it looks a bug! Any experience?
Reproduce code:
---------------
---
From manual page: function.empty
---
Expected result:
----------------
This is not empty
Actual result:
--------------
RESULT:
this is empty
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
> var $vars = {'a'=>'aa', 'b'=>'bb'}; Heh? What does this do and where did you find this snippet?It should be like this: var $vars = array{'a'=>'aa', 'b'=>'bb'};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>";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