Ionut G. Stan wrote:
Hi,
This is interesting and it appears the following change makes the
snippet work as expected:
public function &__get($name);
I think is that the $this->anArray['bar'] = 4;
Generate the following bytcode:
0 FETCH_OBJ_W $0 'anArray'
1 ZEND_ASSIGN_DIM $0, 'bar'
Will the folloing :
echo $this->anArray;
$this->anArray['bar'];
0 FETCH_OBJ_R $0 'anArray'
1 ECHO
...
IMHO I think that the complexity of the VM is way to hight.
That is something I am strongly agree with Gilad Bracha on adding new
feature into a language:
Look at the last paragraph:
http://gbracha.blogspot.com/2009/09/systemic-overload.html
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
--Mathieu Suen
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php