PHP

Copying an Object

<?php
   abstract class dog {
      public function __clone() {
         echo "In dog clone\n";
      }
   }

   class poodle extends dog {
      public $Name;

      public function __clone() {
         echo "In poodle clone\n";
         parent::__clone();
      }
   }

   $poppy = new poodle();
   $poppy->Name = "Poppy";

   $rover = clone $poppy;
?>

José M. Vidal .

26 of 33