php
class Person {
public $name;
public $age;
public function __clone() {
$this->name = 'Clone of ' . $this->name;
}
}
$person1 = new Person();
$person1->name = 'Alice';
$person1->age = 30;
$person2 = clone $person1;
echo $person1->name; // Output: Alice
echo $person2->name; // Output: Clone of Alice
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-