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;
by Valeri Tandilashvili
4 years ago
PHP
OOP
Object Oriented PHP Tutorial
1
Pro tip: use ```triple backticks around text``` to write in code fences