时间:2021-07-01 10:21:17 帮助过:18人阅读
name = 'james'; echo 'james`s name is '.$james->name.'
'; $james2 = clone $james;//克隆 $james2->name = 'james2'; echo 'after assign :
'; echo 'james`s name is '.$james->name.'
'; echo 'james2`s name is '.$james2->name.'
'; $james3 = $james; //赋值 $james3->name = 'james3'; echo 'after assign:
'; echo 'james`s name is '.$james->name.'
'; echo 'james2`s name is '.$james3->name.'
';
运行后结果:
james`s name is james
after clone :
james`s name is james
james2`s name is james2
after assign:
james`s name is james3
james2`s name is james3
以上就介绍了PHP面向对象——clone关键字,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。