时间:2021-07-01 10:21:17 帮助过:17人阅读
$object2 = clone $object;
name=$name; $this->age=$age; } function say() { echo "我的名字叫:".$this->name."
"; echo "我的年龄是:".$this->age; } } $p1 = new Person("张三", 20); $p2 = clone $p1; $p2->say(); ?>
我的名字叫:张三 我的年龄是:20
name = $name; $this->age = $age; } function say() { echo "我的名字叫:".$this->name; echo " 我的年龄是:".$this->age."
"; } function __clone() { $this->name = "我是假的".$this->name; $this->age = 30; } } $p1 = new Person("张三", 20); $p1->say(); $p2 = clone $p1; $p2->say(); ?>
我的名字叫:张三 我的年龄是:20 我的名字叫:我是假的张三 我的年龄是:30
1 楼 meihaoderizi123 2012-08-14
thanks,this article is very helpful to me.