| <?php
class Account{
	private $balance;
	function __construct($balance){
		$this->balance=$balance;
	}
	function setBal($num){
		$this->balance +=$num;
	}
	function getBal(){
		return $this->balance;
	}
}
class Person{
	private $name;
	private $age;
	private $id;
	public $account;
	function __construct($name,$age,Account $account){
		$this->name=$name;
		$this->age=$age;
		$this->account=$account;
	}
	function setId($id){
		$this->id=$id;
	}
	function __clone(){
		$this->id=0;
		$this->account=clone $this->account;
	}
	function get(){
		return $this->name.':'.$this->age.":".$this->id.":".$this->account->getBal();
	}
}
$person=new Person("bob",93,new Account(213));
$person->setId(413);
$person2=clone $person;
$person2->account->setBal(10);
print $person->get();
echo "<br>";
echo $person2->get();
?>
 |