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
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
- 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
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
(
4 matches
Mail list logo