Using the __clone() Method : __clone « Class « PHP
- PHP
- Class
- __clone
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