<?php
/*__clone()魔术方法:
1.当使用clone关键字clone对象时自动调用;
2.使用__clone()魔术方法是为了让新克隆的对象进行初始化重新赋值;
3.这个方法内部的$this代表的是新克隆的对象(副本);
*/
class person{
public $name;
public $age;
public $address;
function __construct($name,$age,$address){
$this->name=$name;
$this->age=$age;
$this->address=$address;
}
function say(){
echo "我的名字叫:".$this->name.",我的年纪是:".$this->age.",我来自:".$this->address."<br>";
}
function __destruct(){
echo "##############byebye<br>";
}
function __clone(){
$this
/*__clone()魔术方法:
1.当使用clone关键字clone对象时自动调用;
2.使用__clone()魔术方法是为了让新克隆的对象进行初始化重新赋值;
3.这个方法内部的$this代表的是新克隆的对象(副本);
*/
class person{
public $name;
public $age;
public $address;
function __construct($name,$age,$address){
$this->name=$name;
$this->age=$age;
$this->address=$address;
}
function say(){
echo "我的名字叫:".$this->name.",我的年纪是:".$this->age.",我来自:".$this->address."<br>";
}
function __destruct(){
echo "##############byebye<br>";
}
function __clone(){
$this