22 Program to demonstrate clonning of object in PHP

Program:


<?php

   

    class CloneDemo

    {

        public $data1;

        public $data2;

        public $data3;

    }



    $c = new CloneDemo;

    $c->data1="Hello";

    $c->data2="From";

    $c->data3="Coding";

       



    $c1 = clone $c;



    $c1->data1="Atharva";

    $c1->data2="Here";

    $c1->data3="";



    echo "$c->data1 $c->data2 $c->data3";

    echo "$c1->data1 $c1->data2 $c1->data3";  

?>


Output:

Program to demonstrate clonning of object in PHP

Previous
Next Post »