class Test{
public $a = 0;
}
$test = new Test();
$subtest = $test;
echo "$test->a/n";
echo "$subtest->a/n";
$subtest->a = 1;
echo "$test->a/n";
echo "$subtest->a/n";
$subtest2 = clone $test;
echo "/n$test->a/n";
echo "$subtest2->a/n";
$subtest2->a = 2;
echo "$test->a/n";
echo "$subtest2->a/n";
?>
/*
php5中,用clone关键字实现克隆操作以创建一个对象的副本。
另外,还可以为类定义一个名为__clone()的方法以执行特定的克隆代码,该方法在使用
clone关键字对类实例进行克隆操作的时候会被自动调用
*/