clone keyword:
<?php
class OS {
var $name;
function OS($name) {
$this->name = $name;
}
}
function changeName($obj, $name) {
$obj->name = $name;
}
$linux = new OS('linux');
$win = clone $linux;
changeName($win, 'windows');
echo $linux->name, "\n", $win->name;
?>
output:
linux
windows