You are here: Re: Array property of object with __get and __set - is this a bug? « PHP « IT news, forums, messages
Re: Array property of object with __get and __set - is this a bug?

Posted by Wayne on 10/20/11 11:31

On 7 Nov 2005 06:34:47 -0800, "ZeldorBlat" <zeldorblat@gmail.com>
wrote:

>No, because makeArray is a function, not a reference or variable. The
>same thing happens when you use __get() and __set(). Although it looks
>like regular property accessing and setting, it really isn't.

Well you're right that you can't do someFunction()[0] but array access
syntax does work for __get and _set. Try this in PHP5 and you'll get
the desired result:

class Test
{
public function __get($name) {
return Array('hello', 'world');
}
public function blah()
{
return Array('hello', 'world');
}
}

$test = new Test();
echo $test->whatever[0];
// displays 'hello'

The original posters problem is entirely different.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация