php
class User {
public $name;
public function __clone() {
echo "Cloning User object\n";
}
}
$user1 = new User();
$user1->name = "Alice";
$user2 = clone $user1;
$user2->name = "Bob";
echo $user1->name; // Output: Alice
echo $user2->name; // Output: Bob
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-