We can create copy of an existing object. This is very useful feature of Object Oriented Programming. In the clone object we can make copy of any Object at run time.
For example, we have an Object which has any account detail of any person and we want to use this Object to new account then we cannot do this.
First of all we have to make copy this Object as new account.
In the above we can understand, first of all we make any Object ($ABC) of Class (Account) and we can copy this Object ($ABC) to new Object ($XYZ) in simple method.
PHP provide new method for copy Object. We can use method “Clone” for create duplicate Object.
For example, we have an Object which has any account detail of any person and we want to use this Object to new account then we cannot do this.

First of all we have to make copy this Object as new account.
Example:
$ABC = new Account();
$XYZ=$ABC;
In the above we can understand, first of all we make any Object ($ABC) of Class (Account) and we can copy this Object ($ABC) to new Object ($XYZ) in simple method.
PHP provide new method for copy Object. We can use method “Clone” for create duplicate Object.
Syntax:
New_Object_Name = Clone Old_Object_Name;
Example:
$abc = new Account();
$XYZ = Clone $ABC;
nice tuts
ReplyDelete