PHP Cloning An Object-Oriented Programming Free Online Tutorial

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.


Make Copy Object in Class


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;

Watch Free Online Video Tutorial in Hindi/Urdu

PHP  Cloning An Objects in OOP Watch Free Online Video Tutorial in Hindi/Urdu


PHP Cloning An Objects OOP - Watch Free Online Video Tutorial in Hindi/Urdu

Comments

Post a Comment