<?php

class my_class
{
    public $var1;

    public $var2;

    public $var3;

	private $data;
	
	public function __construct()
	{
	    $this->data = new stdClass;
	    $this->data->var1 = 'a';
	    $this->data->var2 = 'b';
	    $this->data->var3 = 'c';
	    $this->assignReferences();
	}
	
	public function makeClone()
	{
	    unset($this->var1);  // turns $this->data->var1 into non-reference
	    unset($this->var2);  // turns $this->data->var2 into non-reference
	    unset($this->var3);  // turns $this->data->var3 into non-reference
	
	    $clone = clone $this;               // this code is the same
	    $clone->data = clone $clone->data;  // as what would go into
	    $clone->assignReferences();         // __clone() normally
	
	    $this->assignReferences(); // undo the unset()s
	    return $clone;
	}
	
	private function assignReferences()
	{
	    $this->var1 = &$this->data->var1;
	    $this->var2 = &$this->data->var2;
	    $this->var3 = &$this->data->var3;        
	}
}

$original = new my_class;
$oops = &$original->var3;
$new = $original->makeClone();
$new->var3 = 'd'; 

echo $original->var3; // Output Should Be "c"