Re: Assign array with __get
| From: | Ionut G. Stan | Date: | Wed, 17 Mar 2010 14:13:48 +0000 |
| Subject: | Re: Assign array with __get | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47356@lists.php.net to get a copy of this message | ||
Hi,
This is interesting and it appears the following change makes the snippet work as expected:
public function &__get($name);On 3/17/10 3:55 PM, mathieu.suen wrote:
Hi, I came across a strange behavior when using the magic method __get and some instance variable that should be an array. Consider the following example: class A { public function __get($name) { $this->$name = array(); return $this->$name; } public function test() { $this->_zork['bar'] = 67; } } $a = new A; $a->test(); var_dump($a); So could someone explain me what is the semantic of the above statements? Thanks -- Mathieu Suen-- Ionut G. Stan I'm under construction | http://blog.igstan.ro/