name = "Alice";$user2 = clone $user1;$user2->name = "Bob";echo $user1->name; // Output: Aliceecho $user2->name; // Output:" />
主页 > php易尔灵网络科技

php 如何拷贝对象

129 2024-02-28 04:13

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%
相关评论
我要评论
点击我更换图片

热点提要

网站地图 (共30个专题75551篇文章)

返回首页