clone
function clones the object and __clone
method is going to call when the object gets cloned class User {
public $username;
public $friends = ['Tom','David'];
function __construct($name) {
$this->username = $name;
print $this->username . "'s object is created'\n";
}
function __clone() {
print $this->username . "'s object is cloned'\n";
}
}
$user1 = new User('Tom');
$user2 = clone $user1;