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

2009-10-20 Thread mbneto
Hi Tommy, I've found both approaches (using setter/getter) as recommended/non-recommended in documentation so this will be a difficult decision.Unfortunately I'll not be able to take your way since the Email class (simplified in the example) is going to be used in other classes as well. On S

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've done like this > > class E

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 (