I consider this a bug in PHP itself, personally. The solution is changing
__get to something more like this:
// Zend_View_Abstract::__get()
public function __get($key)
{
if ($key[0] != '_') {
if (!isset($this->_vars[$key])) {
$this->_vars[$key] = null;
}
return $this->_vars[$key];
}
}
This is because when you call $this->a[] = 1, PHP actually calls __get
instead of __set. There is no warning, error, or anything. It just
silently fails.
-Matt
----- Original Message -----
From: "Carolina Feher da Silva" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, October 31, 2006 7:32 PM
Subject: [fw-general] Strange array bug?
Please paste this code in a view:
$this->a = array();
$this->a[] = 1;
print_r($this->a);
What do you get? I get an *empty* array. How come? I don't understand it.