Assign array with __get

From: Date: Wed, 17 Mar 2010 13:55:45 +0000
Subject: Assign array with __get
Groups: php.internals 
Request: Send a blank email to internals+get-47355@lists.php.net to get a copy of this message
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

« previous php.internals (#47355) next »