Using the clone Statement : __clone « Class « PHP






Using the clone Statement

 
<?php
     class Integer {
          private $number;
          public function getInt() {
               return (int)$this->number;
          }
          public function setInt($num) {
               $this->number = (int)$num;
          }
     }
     
     $class_one = new Integer();
     $class_one_copy = clone $class_one;
?>
  
  








Related examples in the same category

1.Using the __clone() Method