Object Cloning
Object Cloning :
Object cloning is the
process of creating a copy of an object with fully replicated properties. An
object copy is created by using “clone” keyword which calls the objects.
__clone() methid. An object __clone() method cannot be called directly.
$copy-object = clone object;
Object Cloning Example :
<?php
class
A
{
public $x=11;
}
?>
<?php
$o1
= new A();
$o2
= clone $o1;
echo
$o1->x."--".$o2->x."<br>";
$o2->x=22;
echo
$o1->x."--".$o2->x;
?>
OutPut:
11-1111--22
Object Cloning, php object cloning, cloning, object cloning php.
0 comments:
Post a Comment