Copying an Object
| From: | Daniel Kolbo | Date: | Wed, 22 Sep 2010 11:35:36 +0000 |
| Subject: | Copying an Object | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-308252@lists.php.net to get a copy of this message | ||
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. Class
A extends 3 other classes. I would like a way to not have to manage a
'copy' method in B if A or one of the subclasses of A change.
I was reading about clone, but this doesn't really seem to help me in
this situation.
How can I copy $a into $b?
Thanks,
dK
`