Re: [PHP] Copying an Object

2010-09-24 Thread Nathan Nobbe
On Thu, Sep 23, 2010 at 12:24 AM, Peter Lind wrote: > On 23 September 2010 02:14, Daniel Kolbo wrote: > > *snip* > > > On 9/22/2010 9:11 AM, chris h wrote: > > Say you have two classes: human and male. Further, say male extends > > human. Let's say you have a human object. Then later you want

Re: [PHP] Copying an Object

2010-09-23 Thread Carlos Medina
Am 23.09.2010 08:24, schrieb Peter Lind: On 23 September 2010 02:14, Daniel Kolbo wrote: *snip* On 9/22/2010 9:11 AM, chris h wrote: Say you have two classes: human and male. Further, say male extends human. Let's say you have a human object. Then later you want to make that human object a

Re: [PHP] Copying an Object

2010-09-22 Thread Peter Lind
On 23 September 2010 02:14, Daniel Kolbo wrote: *snip* > On 9/22/2010 9:11 AM, chris h wrote: > Say you have two classes: human and male.  Further, say male extends > human.  Let's say you have a human object.  Then later you want to make > that human object a male object.  This seems to be a pr

Re: [PHP] Copying an Object

2010-09-22 Thread Daniel Kolbo
On 9/22/2010 9:11 AM, chris h wrote: > > You could create a method of class B that takes an object of class A as > a parameter and copies each property line by line (or method of class A > that takes an object of class B...). If you don't want to add a method > you could just do the same thing, b

Re: [PHP] Copying an Object

2010-09-22 Thread Nathan Nobbe
On Wed, Sep 22, 2010 at 5:35 AM, Daniel Kolbo wrote: > Hello PHPers, > > I have: > > class A { >...code > } > > class B extends A { >...code > } > > $a = new A(); > > $b = new B(); > after looking back over your situation, which looks strange, why not use composition at this leve

Re: [PHP] Copying an Object

2010-09-22 Thread Nathan Nobbe
On Wed, Sep 22, 2010 at 5:35 AM, Daniel Kolbo wrote: > Hello PHPers, > > I have: > > class A { >...code > } > > class B extends A { >...code > } > > $a = new A(); > > $b = new B(); > > I would like to get all of the properties of $a into $b by value. first off you have to be car

Re: [PHP] Copying an Object

2010-09-22 Thread chris h
You could create a method of class B that takes an object of class A as a parameter and copies each property line by line (or method of class A that takes an object of class B...). If you don't want to add a method you could just do the same thing, but procedurally. The issue with this (aside fro

Re: [PHP] Copying an Object

2010-09-22 Thread mr bungle
Maybe statics members can help you with this ... On Wed, Sep 22, 2010 at 07:35, Daniel Kolbo wrote: > Hello PHPers, > > I have: > > class A { >...code > } > > class B extends A { >...code > } > > $a = new A(); > > $b = new B(); > > I would like to get all of the properties of $a