Using the __clone() Method : __clone « Class « PHP






Using the __clone() Method

 
<?php
     class myObject {
          public $var_one = 10;
          public $var_two = 20;
          function __clone() {
                    $this->var_two = 0;
          }
     }
     $inst_one = new myObject();
     $inst_two = clone $inst_one;
     var_dump($inst_one);
     var_dump($inst_two);
?>
  
  








Related examples in the same category

1.Using the clone Statement