From the code below, does anyone know of a way to put the value of $parent->foo and $parent->foo1 into $child->bar and $child->bar1, respectively, from a method defined in B?
I can copy the values with $child->bar=$parent->foo and $child->bar1=$parent->foo1 outside the objects but it feels like there could be a simple method in the child (or even the parent for that matter) for this situation. My parent object is getting the values of the foo’s from html input boxes.
Class A
{
public $foo="someText";
public $foo1="someOtherText";
}
Class B extends A
{
public $bar;
public $bar1;
//theoretical function Id like to use
public copyParentcontents()
{
}
}
$parent = new A();
$child = new B();
and then:
Perhaps this is what you need?