Sep 062010
Clone an object in PHP
Answer:
It is easy to clone an object in PHP, using the following method.
<?php
$obj = new stdClass();
$obj->foo = "foo";
$obj->bar = "bar";
$new_obj = clone $obj;
var_dump ( new_obj );
It will print out...
object(stdClass)#2 (2) {
["foo"]=>
string(3) "foo"
["bar"]=>
string(3) "bar"
}