Re: [PHP] Using setters/getters with array of objects

2009-10-20 Thread mbneto
well. On Sun, Oct 18, 2009 at 1:24 PM, Tommy Pham wrote: > - Original Message > > From: mbneto > > To: php-general@lists.php.net > > Sent: Sun, October 18, 2009 8:31:53 AM > > Subject: [PHP] Using setters/getters with array of objects > > > > Hi

Re: [PHP] Using setters/getters with array of objects

2009-10-20 Thread mbneto
Hi, Thanks. I'll probably do the addEmail method. I was hoping to do as with the other "non-array" properties. On Sun, Oct 18, 2009 at 1:00 PM, Andy Shellam (Mailing Lists) wrote: > Hi, > > > $u->emails[] = $e; > > > I would hazard a guess because $u->emails isn't a concrete object (whereas

Re: [PHP] Using setters/getters with array of objects

2009-10-18 Thread Tommy Pham
- Original Message > From: mbneto > To: php-general@lists.php.net > Sent: Sun, October 18, 2009 8:31:53 AM > Subject: [PHP] Using setters/getters with array of objects > > Hi, > > I have two classes User and Email where one User can have many Emails so > I&#

Re: [PHP] Using setters/getters with array of objects

2009-10-18 Thread Andy Shellam (Mailing Lists)
Hi, $u->emails[] = $e; I would hazard a guess because $u->emails isn't a concrete object (whereas $u->_emails is, but is private.) It's sort of a virtual reference - PHP has no way of knowing that $u->emails actually translates into _emails which is an array, if you see what I mean (

[PHP] Using setters/getters with array of objects

2009-10-18 Thread mbneto
Hi, I have two classes User and Email where one User can have many Emails so I've done like this class Email { protected $_email; public function __get($name) { $property = '_' . $name; return $this->$property; } public function __set($name, $value) {