is it possible to easily and quickly “assigning properties of one object to another”
class a {
public $number_one;
public $number_two;
public $number_three;
function __contruct() {
//do stuff
}
}
class b {
public $my_var;
function __contruct() {
$instanc_a = new a();
extract( $instance ); // but make these extracted object properties of class b????
// how? :-(
echo $this->number_one;
}
}
You can use
get_object_varsto copy the public (only) properties ofclass ato the current object:See it in action.
Note: You have a typo in your code (two cases of “contruct” instead of “construct”) which will prevent things from working as they should.